Parent

Midi

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...

Public Class Methods

new(status, channel, data1, data2) → Midi click to toggle source
new(String) → Midi

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

Public Instance Methods

bytes → Fixnum click to toggle source

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
channel → Integer click to toggle source

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
channel=(Fixnum) click to toggle source

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
data1 → Integer click to toggle source

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
data1=(Fixnum) click to toggle source

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
data2 → Integer click to toggle source

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
data2=(Fixnum) click to toggle source

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
status → Integer click to toggle source

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
status=(Fixnum) click to toggle source

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
sysex → String click to toggle source

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
sysex=(String) click to toggle source

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
to_array → Array click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.