Module: MIDIMessage::SystemExclusive
- Defined in:
- lib/midi-message/system_exclusive.rb
Overview
MIDI System-Exclusive Messages (SysEx)
Defined Under Namespace
Modules: Base Classes: Command, Message, Node, Request
Class Method Summary collapse
-
.new(*bytes) ⇒ Object
convert raw MIDI data to SysEx message objects.
Class Method Details
.new(*bytes) ⇒ Object
convert raw MIDI data to SysEx message objects
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/midi-message/system_exclusive.rb', line 210 def self.new(*bytes) start_status = bytes.shift end_status = bytes.pop return nil unless start_status.eql?(0xF0) && end_status.eql?(0xF7) type_byte = bytes[3] # if the 4th byte isn't status, we will just make this a Message object -- this may need some tweaking if type_byte == 0x11 msg_class = Request elsif type_byte == 0x12 msg_class = Command else return Message.new(bytes) end = bytes.slice!(0,7) manufacturer_id = [0] device_id = [1] model_id = [2] address = .slice(4,3) checksum = bytes.slice!((bytes.length - 1), 1) value = bytes node = Node.new(manufacturer_id, :model_id => model_id, :device_id => device_id) msg_class.new(address, value, :checksum => checksum, :node => node) end |