Module: MIDIMessage::NoteMessage
Overview
Common Note Message Behavior
Class Method Summary collapse
Instance Method Summary collapse
-
#abs_note ⇒ Fixnum
How many half-steps is this note above the closest C.
-
#note_name ⇒ String
The name of the note without its octave e.g.
-
#octave ⇒ Fixnum
(also: #oct)
The octave number of the note.
-
#octave=(value) ⇒ NoteMessage
(also: #oct=)
Set the octave number of the note.
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/midi-message/note_message.rb', line 6 def self.included(base) base.send(:include, ChannelMessage) end |
Instance Method Details
#abs_note ⇒ Fixnum
How many half-steps is this note above the closest C
28 29 30 |
# File 'lib/midi-message/note_message.rb', line 28 def abs_note note - ((note / 12) * 12) end |
#note_name ⇒ String
The name of the note without its octave e.g. F#
34 35 36 |
# File 'lib/midi-message/note_message.rb', line 34 def note_name name.split(/-?\d\z/).first unless name.nil? end |
#octave ⇒ Fixnum Also known as: oct
The octave number of the note
12 13 14 |
# File 'lib/midi-message/note_message.rb', line 12 def octave (note / 12) - 1 end |
#octave=(value) ⇒ NoteMessage Also known as: oct=
Set the octave number of the note
20 21 22 23 |
# File 'lib/midi-message/note_message.rb', line 20 def octave=(value) self.note = ((value + 1) * 12) + abs_note self end |