Module: MIDIMessage::NoteMessage

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

Overview

Common Note Message Behavior

Class Method Summary collapse

Instance Method Summary collapse

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_noteFixnum

How many half-steps is this note above the closest C

Returns:

  • (Fixnum)

28
29
30
# File 'lib/midi-message/note_message.rb', line 28

def abs_note
  note - ((note / 12) * 12)
end

#note_nameString

The name of the note without its octave e.g. F#

Returns:

  • (String)

34
35
36
# File 'lib/midi-message/note_message.rb', line 34

def note_name
  name.split(/-?\d\z/).first unless name.nil?
end

#octaveFixnum Also known as: oct

The octave number of the note

Returns:

  • (Fixnum)

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

Parameters:

  • value (Fixnum)

Returns:


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