Module: MIDIMessage::NoteMessage

Included in:
NoteOff, NoteOn
Defined in:
lib/midi-message/note_message.rb

Overview

Common Note Message Behavior

Instance Method Summary collapse

Instance Method Details

#abs_noteObject

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_nameObject

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

#octaveObject 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