Module: MIDIMessage::SystemExclusive
- Includes:
- MIDIMessage
- Defined in:
- lib/midi-message/system_exclusive.rb,
lib/midi-message/messages.rb
Overview
MIDI System-Exclusive Messages (SysEx)
Defined Under Namespace
Modules: InstanceMethods Classes: Command, Message, Node, Request
Constant Summary
Constants included from MIDIMessage
ChannelPressure, Controller, PolyAftertouch, PolyPressure, PolyphonicPressure, VERSION
Class Method Summary collapse
- .included(base) ⇒ Object
-
.new(*bytes) ⇒ Object
Convert raw MIDI data to SysEx message objects.
Methods included from MIDIMessage
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/midi-message/system_exclusive.rb', line 8 def self.included(base) base.send(:include, InstanceMethods) end |
.new(*bytes) ⇒ Object
Convert raw MIDI data to SysEx message objects
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/midi-message/system_exclusive.rb', line 187 def self.new(*bytes) start_status = bytes.shift end_status = bytes.pop if start_status == 0xF0 && end_status == 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 end |