Module: MIDIMessage::ShortMessage
- Included in:
- ChannelAftertouch, ControlChange, NoteOff, NoteOn, PitchBend, PolyphonicAftertouch, ProgramChange, RawChannelMessage, SystemCommon, SystemRealtime
- Defined in:
- lib/midi-message/short_message.rb
Overview
common behavior amongst all Message types
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#verbose_name ⇒ Object
readonly
Returns the value of attribute verbose_name.
Instance Method Summary collapse
- #initialize_short_message(status_nibble_1, status_nibble_2) ⇒ Object
-
#to_a ⇒ Object
(also: #to_byte_a, #to_byte_array, #to_bytes)
byte array representation of the object eg [0x90, 0x40, 0x40] for NoteOn(0x40, 0x40).
-
#to_hex_s ⇒ Object
(also: #to_bytestr)
string representation of the object’s bytes eg “904040” for NoteOn(0x40, 0x40).
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/midi-message/short_message.rb', line 9 def name @name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/midi-message/short_message.rb', line 9 def status @status end |
#verbose_name ⇒ Object (readonly)
Returns the value of attribute verbose_name.
9 10 11 |
# File 'lib/midi-message/short_message.rb', line 9 def verbose_name @verbose_name end |
Instance Method Details
#initialize_short_message(status_nibble_1, status_nibble_2) ⇒ Object
13 14 15 16 |
# File 'lib/midi-message/short_message.rb', line 13 def (status_nibble_1, status_nibble_2) @status = [status_nibble_1, status_nibble_2] populate_using_const end |
#to_a ⇒ Object Also known as: to_byte_a, to_byte_array, to_bytes
byte array representation of the object eg [0x90, 0x40, 0x40] for NoteOn(0x40, 0x40)
19 20 21 22 |
# File 'lib/midi-message/short_message.rb', line 19 def to_a data = @data.nil? ? [] : [@data[0], @data[1]] [(@status[0] << 4) + @status[1], *data].compact end |
#to_hex_s ⇒ Object Also known as: to_bytestr
string representation of the object’s bytes eg “904040” for NoteOn(0x40, 0x40)
28 29 30 |
# File 'lib/midi-message/short_message.rb', line 28 def to_hex_s TypeConversion.numeric_byte_array_to_hex_string(to_a) end |