Module: MIDIMessage::Message

Defined in:
lib/midi-message/message.rb

Overview

Common behavior amongst all Message types

Instance Method Summary collapse

Instance Method Details

#initialize_message(status_nibble_1, status_nibble_2) ⇒ Object

Initialize the message status

Parameters:

  • status_nibble_1 (Fixnum)

    The first nibble of the status

  • status_nibble_2 (Fixnum)

    The second nibble of the status



9
10
11
12
# File 'lib/midi-message/message.rb', line 9

def initialize_message(status_nibble_1, status_nibble_2)
  @status = [status_nibble_1, status_nibble_2]
  populate_using_const
end

#to_aArray<Fixnum> Also known as: to_byte_a, to_byte_array, to_bytes

Byte array representation of the message eg [0x90, 0x40, 0x40] for NoteOn(0x40, 0x40)

Returns:

  • (Array<Fixnum>)

    The array of bytes in the MIDI message



16
17
18
19
20
# File 'lib/midi-message/message.rb', line 16

def to_a
  data = [@data[0], @data[1]] unless @data.nil?
  data ||= []
  [status_as_byte, *data].compact
end

#to_hex_sString Also known as: to_bytestr

String representation of the message’s bytes eg “904040” for NoteOn(0x40, 0x40)

Returns:

  • (String)

    The bytes of the message as a string of hex bytes



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

def to_hex_s
  TypeConversion.numeric_byte_array_to_hex_string(to_a)
end

#updateObject



32
33
34
# File 'lib/midi-message/message.rb', line 32

def update
  populate_using_const
end