Object
Midi objects each encapsulate a single MIDI message. This may be a "standard" three byte message, such as a note-on, program change or continuous controller; or could be a hexadecimal string containing System Exclusive data.
Like the FlowStone MIDI primitives, 'standard' three byte messages are split into four values, so that the data type and channel can be manipulated independently.
The four data values are as follows...
status The type of message to send. This consists of only the upper four bits (first hex character) of the initial MIDI data byte. This sets the kind of message to send, and is equivalent to the status byte of a message sent on MIDI channel 1 (index zero in the raw byte format). The valid values are as follows...
128 -> Note Off
144 -> Note On
160 -> Polphonic Aftertouch
176 -> Continuous Controller
192 -> Program Change
208 -> Channel Aftertouch
224 -> Pitch Bend
240 -> System message
channel The channel on which the message should be sent. Note that this is indexed as 1 though to 16, not 0-15 as it would be in a raw MIDI status byte.
data1 First byte of the specific data for this message. What this represents will depend on the status value. Value is always from 0 to 255.
For note-on, note-off, poly aftertouch -> the note number
For continuous controller -> the controller ID
For program change -> the program ID
For channel aftertouch -> aftertouch amount
For Pitch Bend -> Coarse pitch bend amount (63 = no shift)
data2 Second byte of the specific data for this message. What this represents will depend on the status value. Value is always from 0 to 255.
For note-on, note-off -> Velocity
For poly aftertouch -> Aftertouch amount
For continuous controller -> the controller value
For program change -> not used
For channel aftertouch -> not used
For Pitch Bend -> Fine pitch bend amount
Create a new MIDI object, which may then be sent to a RubyEdit output to find its way to a hardware or VST MIDI output.
The first form takes four integers, and defines a standard 3-byte MIDI message. See the main class notes at the top of the page for a more detailed description of what these mean.
To create a system exclusive message, give a String containing a list of hexadecimal values (these should be contiguous, not split by separators). The leading start-message (F0) and end-message (F7) bytes must be included.
Example:
# A soft note-on message on channel two... Midi.new(144, 2, 63, 25) # System exclusive message... Midi.new("F01A2B3C4D5EF7")
# File Midi and Audio Classes.rb, line 69 def self.new #DUMMY end
If the Midi object contains a System Exclusive message, this will return the number of bytes in the message. Zero is returned for any other kind of MIDI message.
# File Midi and Audio Classes.rb, line 157 def bytes # DUMMY end
Returns the channel of the MIDI message - this will be zero if the Midi object contains Sytem Exclusive data.
The channel is always indexed from 1 to 16.
# File Midi and Audio Classes.rb, line 94 def channel #DUMMY end
Set the channel of the Midi object. This may not have the desired effect if the Midi object was defined as a System Exclusive message.
The method signature allows a very intuitive syntax to be used...
# Create a new note-on MIDI message on channel 1 @my_midi = Midi.new(144, 1, 63, 63) # Change the channel @my_midi.channel = 12
Channel value is always indexed from 1 to 16.
# File Midi and Audio Classes.rb, line 198 def channel=(val) #DUMMY end
Returns the 'data1' byte of the MIDI message - this will always be zero for a Midi object containing System Exclusive data.
See the class description at the top of the page for details of what this data represents.
# File Midi and Audio Classes.rb, line 107 def data1 #DUMMY end
Set the data1 byte of the Midi object. This may not have the desired effect if the Midi object was defined as a System Exclusive message.
The method signature allows a very intuitive syntax to be used...
# Create a new note-on MIDI message on channel 1 @my_midi = Midi.new(144, 1, 63, 63) # Transpose the note @my_midi.data1 = 67
See the class description at the top of the page for details of what this data represents.
# File Midi and Audio Classes.rb, line 218 def data1=(val) #DUMMY end
Returns the 'data2' byte of the MIDI message - this will always be zero for a Midi object containing System Exclusive data.
See the class description at the top of the page for details of what this data represents.
# File Midi and Audio Classes.rb, line 120 def data2 #DUMMY end
Set the data2 byte of the Midi object. This may not have the desired effect if the Midi object was defined as a System Exclusive message.
The method signature allows a very intuitive syntax to be used...
# Create a new note-on MIDI message on channel 1 @my_midi = Midi.new(144, 1, 63, 63) # Change the velocity @my_midi.data2 = 127
See the class description at the top of the page for details of what this data represents.
# File Midi and Audio Classes.rb, line 238 def data2=(val) #DUMMY end
Returns the status code of the MIDI message - this will be zero if the Midi object contains System Exclusive data.
See the class description at the top of the page for details of what this data represents.
# File Midi and Audio Classes.rb, line 82 def status #DUMMY end
Set the status byte of the Midi object. Take care if doing this, as changing the status changes the meaning of the 'data1' and 'data2' values. It may also not have the desired effect if the Midi object was defined as a System Exclusive message.
The method signature allows a very intuitive syntax to be used...
# Create a new note-on MIDI message on channel 1 @my_midi = Midi.new(144, 1, 63, 63) # Change to a note-off message @my_midi.status = 128
See the class description at the top of the page for details of what this data represents.
# File Midi and Audio Classes.rb, line 179 def status=(val) #DUMMY end
If the Midi object contains a System Exclusive message, this will return a hexadecimal String containing the whole message. An empty String is returned for any other kind of MIDI message.
# File Midi and Audio Classes.rb, line 146 def sysex # DUMMY end
Assign a new Sysex message to the Midi object. This should be an unbroken list of hexadecimal bytes, complete with 'start-message' (F0) and 'end-message' (F7) bytes. The effect may be unpredictable if the Midi object was not already defined as a System Exclusive message.
# File Midi and Audio Classes.rb, line 251 def sysex=(val) #DUMMY end
Returns an array containing the data that describes the MIDI message. For a 'standard' MIDI message this will contain four integers...
[status, channel, data1, data2]
For a System Exclusive message, it will contain a String followed by an Integer. The String is the entire System Exclusive message in hexadecimal format, and the Integer gives the number of bytes of data.
# File Midi and Audio Classes.rb, line 135 def to_array #DUMMY end
Generated with the Darkfish Rdoc Generator 2.