Class: JSound::Midi::Messages::PitchBend

Inherits:
JSound::Midi::Message show all
Defined in:
lib/jsound/midi/messages/pitch_bend.rb

Constant Summary

Constants inherited from JSound::Midi::Message

JSound::Midi::Message::CLASS_FOR_STATUS, JSound::Midi::Message::STATUS_FOR_CLASS, JSound::Midi::Message::STATUS_FOR_TYPE, JSound::Midi::Message::TYPE_FOR_STATUS

Instance Attribute Summary collapse

Attributes inherited from JSound::Midi::Message

#channel, #data, #source, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from JSound::Midi::Message

#==, #data1, #data1=, #data2, #data2=, inherited, #status, #to_java, #to_s, #update_java_message

Methods included from TypeFromClassName

included

Constructor Details

#initialize(value, channel = 0, options = {}) ⇒ PitchBend

Returns a new instance of PitchBend.



9
10
11
12
# File 'lib/jsound/midi/messages/pitch_bend.rb', line 9

def initialize(value, channel=0, options={})
  super(nil, channel, options)
  self.value = value # we set #data as a side-effect here
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/jsound/midi/messages/pitch_bend.rb', line 7

def value
  @value
end

Class Method Details

.from_f(f, channel = 0, options = {}) ⇒ Object

Parameters:

  • f (Float)

    in the range -1.0 to 1.0



26
27
28
# File 'lib/jsound/midi/messages/pitch_bend.rb', line 26

def self.from_f(f, channel=0, options={})
  new Convert.normalized_float_to_14bit(f), channel=0, options
end

.from_java(java_message, options = {}) ⇒ Object



30
31
32
33
# File 'lib/jsound/midi/messages/pitch_bend.rb', line 30

def self.from_java(java_message, options={})
  value = Convert.from_7bit(java_message.data1, java_message.data2)
  new value, java_message.channel, options.merge({:java_message => java_message})
end

Instance Method Details

#cloneObject



35
36
37
# File 'lib/jsound/midi/messages/pitch_bend.rb', line 35

def clone
  self.class.new(@value,@channel)
end

#data=(data) ⇒ Object



20
21
22
23
# File 'lib/jsound/midi/messages/pitch_bend.rb', line 20

def data= data
  super
  @value = Convert.from_7bit(*data)
end