Module: MIDIMessage::NoteMessage
Overview
Common Note Message Behavior
Instance Method Summary collapse
-
#abs_note ⇒ Object
how many half-steps is this note above the closest C.
-
#note_name ⇒ Object
the name of the note without its octave e.g.
-
#octave ⇒ Object
(also: #oct)
the octave number of the note.
-
#octave=(val) ⇒ Object
(also: #oct=)
set the octave number of the note.
Instance Method Details
#abs_note ⇒ Object
how many half-steps is this note above the closest C
24 25 26 |
# File 'lib/midi-message/note_message.rb', line 24 def abs_note note - ((note / 12) * 12) end |
#note_name ⇒ Object
the name of the note without its octave e.g. F#
29 30 31 |
# File 'lib/midi-message/note_message.rb', line 29 def note_name name.split(/-?\d\z/).first end |
#octave ⇒ Object Also known as: oct
the octave number of the note
11 12 13 |
# File 'lib/midi-message/note_message.rb', line 11 def octave (note / 12) -1 end |
#octave=(val) ⇒ Object Also known as: oct=
set the octave number of the note
17 18 19 20 |
# File 'lib/midi-message/note_message.rb', line 17 def octave=(val) self.note = ((val + 1) * 12) + abs_note self end |