Class: MIDI::PitchBend

Inherits:
ChannelEvent show all
Defined in:
lib/midilib/event.rb

Instance Attribute Summary collapse

Attributes inherited from ChannelEvent

#channel

Attributes inherited from Event

#delta_time, #print_decimal_numbers, #print_note_names, #status, #time_from_start

Instance Method Summary collapse

Methods inherited from Event

#<=>, #channel?, #meta?, #note?, #note_off?, #note_on?, #number_to_s, #quantize_to, #realtime?, #system?

Constructor Details

#initialize(channel = 0, value = 0, delta_time = 0) ⇒ PitchBend

Returns a new instance of PitchBend.



276
277
278
279
# File 'lib/midilib/event.rb', line 276

def initialize(channel = 0, value = 0, delta_time = 0)
	super(PITCH_BEND, channel, delta_time)
	@value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



274
275
276
# File 'lib/midilib/event.rb', line 274

def value
  @value
end

Instance Method Details

#data_as_bytesObject



281
282
283
284
285
286
287
# File 'lib/midilib/event.rb', line 281

def data_as_bytes
	data = ''
	data << (@status + @channel)
	data << ((@value >> 8) & 0xff) # msb
	data << (@value & 0xff) # lsb
	return data
end

#to_sObject



289
290
291
# File 'lib/midilib/event.rb', line 289

def to_s
	return super << "pb #{number_to_s(@value)}"
end