Class: MIDIEvents::SystemCommon

Inherits:
Object
  • Object
show all
Includes:
SystemMessage
Defined in:
lib/midi-events/messages.rb

Overview

MIDI System-Common message

Constant Summary collapse

ID =
(0x1..0x6).freeze
DISPLAY_NAME =
'System Common'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ SystemCommon

Returns a new instance of SystemCommon.



118
119
120
121
122
123
124
125
# File 'lib/midi-events/messages.rb', line 118

def initialize(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  @const = options[:const]
  id = @const.nil? ? args.shift : @const.value
  id = strip_redundant_nibble(id)
  initialize_message(SystemMessage::STATUS, id)
  @data = args.slice(0..1)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



116
117
118
# File 'lib/midi-events/messages.rb', line 116

def data
  @data
end

Instance Method Details

#strip_redundant_nibble(byte) ⇒ Fixnum Originally defined in module SystemMessage

In the case of something like SystemCommon.new(0xF2, 0x00, 0x08), the first nibble F is redundant because all system messages start with 0xF and it can be assumed. However, the this method looks to see if this has occurred and strips the redundancy

Parameters:

  • byte (Fixnum)

    The byte to strip of a redundant 0xF

Returns:

  • (Fixnum)

    The remaining nibble