class MIDI::NoteEvent
The abstract superclass of all note on, and note off, and polyphonic pressure events.
Constants
- PITCHES
Attributes
note[RW]
velocity[RW]
Public Class Methods
new(status, channel, note, velocity, delta_time)
click to toggle source
Calls superclass method
MIDI::ChannelEvent::new
# File lib/midilib/event.rb, line 103 def initialize(status, channel, note, velocity, delta_time) super(status, channel, delta_time) @note = note @velocity = velocity end
Public Instance Methods
data_as_bytes()
click to toggle source
# File lib/midilib/event.rb, line 125 def data_as_bytes data = [] data << (@status + @channel) data << @note data << @velocity end
note_to_s()
click to toggle source
If @print_note_names is true, returns pch_oct
(val) else returns value as a number using number_to_s.
# File lib/midilib/event.rb, line 121 def note_to_s @print_note_names ? pch_oct(@note) : number_to_s(@note) end
pch_oct(val = @note)
click to toggle source
Returns note name as a pitch/octave string like “C4” or “F#6”.
# File lib/midilib/event.rb, line 113 def pch_oct(val = @note) pch = val % 12 oct = (val / 12) - 1 "#{PITCHES[pch]}#{oct}" end