Class: MIDIEvents::SystemRealtime

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

Overview

MIDI System-Realtime message

Constant Summary collapse

ID =
(0x8..0xF).freeze
DISPLAY_NAME =
'System Realtime'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ SystemRealtime

Returns a new instance of SystemRealtime.



137
138
139
140
141
142
143
# File 'lib/midi-events/messages.rb', line 137

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

Instance Method Details

#idObject



145
146
147
# File 'lib/midi-events/messages.rb', line 145

def id
  @status[1]
end

#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