Class: Vissen::Input::Message::Note
- Defined in:
- lib/vissen/input/message/note.rb
Overview
From the MIDI Association:
Note On event.
This is sent when a note is depressed (start).
Note Off event.
This is sent when a note is released (ended).
Constant Summary collapse
- STATUS_MASK =
0xE0
- STATUS =
0x80- NOTE_ON =
0x10- NOTE_OFF =
0x00
Constants inherited from Base
Constants included from Vissen::Input::Message
Instance Attribute Summary
Attributes included from Vissen::Input::Message
Class Method Summary collapse
Instance Method Summary collapse
-
#note ⇒ Integer
The note value.
-
#off? ⇒ true, false
True if the note was released.
-
#on? ⇒ true, false
True if the note was depressed.
-
#velocity ⇒ Integer
The velocity value.
Methods inherited from Base
[], factory, match?, matcher, #valid?
Methods included from Vissen::Input::Message
#channel, #initialize, #status, #valid?
Class Method Details
.create(*bytes, on: true, **args) ⇒ Note
44 45 46 |
# File 'lib/vissen/input/message/note.rb', line 44 def create(*bytes, on: true, **args) super(*bytes, status: STATUS + (on ? NOTE_ON : NOTE_OFF), **args) end |
Instance Method Details
#note ⇒ Integer
Returns the note value.
19 20 21 |
# File 'lib/vissen/input/message/note.rb', line 19 def note data[1] end |
#off? ⇒ true, false
Returns true if the note was released.
29 30 31 |
# File 'lib/vissen/input/message/note.rb', line 29 def off? (data[0] & NOTE_ON).zero? end |
#on? ⇒ true, false
Returns true if the note was depressed.
34 35 36 |
# File 'lib/vissen/input/message/note.rb', line 34 def on? !off? end |
#velocity ⇒ Integer
Returns the velocity value.
24 25 26 |
# File 'lib/vissen/input/message/note.rb', line 24 def velocity data[2] end |