File Duplex/MidiDevice.lua

Functions

MidiDevice:__init (display_name, message_stream, port_in, port_out) Initialize MidiDevice class
MidiDevice:_midi_cc_to_string (int) Convert MIDI CC value to string, e.g.
MidiDevice:_note_to_string (int) Convert MIDI note to control-map string, range 0 (C--1) to 120 (C-9)
MidiDevice:extract_midi_cc (str) Extract MIDI CC number (range 0-127)
MidiDevice:extract_midi_channel (str) Determine channel for the given message (use default port if not specified)
MidiDevice:extract_midi_note (str) Extract MIDI note-value (range C--1 to C9)
MidiDevice:midi_callback (message) Invoked when we receive MIDI from device, construct a string identical to the value attribute, which is then used to locate the parameter in the control-map
MidiDevice:open () Attempt to open the device MIDI ports
MidiDevice:point_to_value (pt, elm, ceiling) Convert the point to an output value
MidiDevice:release () Attempt to release the device MIDI ports
MidiDevice:send_cc_message (number, value, channel) Send CC message to device
MidiDevice:send_note_message (key, velocity, channel) Send note message to device
MidiDevice:send_pitch_bend_message (value, channel) Send Pitch-Bend message to device
MidiDevice:send_sysex_message (...) Send sysex message to device (adding the initial 0xF0 and 0xF7 values)
MidiDevice:sysex_callback (message) Invoked when we receive sysex data from the device


Functions

MidiDevice:__init (display_name, message_stream, port_in, port_out)
Initialize MidiDevice class

Parameters:

  • display_name: (String) the friendly name of the device
  • message_stream: (MessageStream) the msg-stream we should attach to
  • port_in: (String) the MIDI input port
  • port_out: (String) the MIDI output port
MidiDevice:_midi_cc_to_string (int)
Convert MIDI CC value to string, e.g. "CC#%d"

Parameters:

  • int: (Number/7BitInt) the CC number
MidiDevice:_note_to_string (int)
Convert MIDI note to control-map string, range 0 (C--1) to 120 (C-9)

Parameters:

  • int: (Number/7BitInt): the MIDI note key

Return value:

    String
MidiDevice:extract_midi_cc (str)
Extract MIDI CC number (range 0-127)

Parameters:

  • str: (string, control-map value attribute)

Return value:

    (Number) the MIDI CC number, 0-127
MidiDevice:extract_midi_channel (str)
Determine channel for the given message (use default port if not specified)

Parameters:

  • str: (String), control-map value)

Return value:

    (Number) the MIDI channel, 1-16
MidiDevice:extract_midi_note (str)
Extract MIDI note-value (range C--1 to C9)

Parameters:

  • str: (String), control-map value such as "C-4" or "F#-1"

Return value:

    (Number) the MIDI note pitch, 0-127
MidiDevice:midi_callback (message)
Invoked when we receive MIDI from device, construct a string identical to the value attribute, which is then used to locate the parameter in the control-map

Parameters:

  • message: (Table/MIDIMessage)
MidiDevice:open ()
Attempt to open the device MIDI ports
MidiDevice:point_to_value (pt, elm, ceiling)
Convert the point to an output value

Parameters:

  • pt: (CanvasPoint)
  • elm: (Table), control-map parameter
  • ceiling: (Number), the UIComponent ceiling value

Return value:

    (Number), the output value
MidiDevice:release ()
Attempt to release the device MIDI ports
MidiDevice:send_cc_message (number, value, channel)
Send CC message to device

Parameters:

  • number: (Number/7BitInt) the control-number
  • value: (Number/7BitInt) the control-value
  • channel: (Number) the midi channel, between 1-16
MidiDevice:send_note_message (key, velocity, channel)
Send note message to device

Parameters:

  • key: (Number) the MIDI note pitch
  • velocity: (Number) the MIDI note velocity
  • channel: (Number) the MIDI channel
MidiDevice:send_pitch_bend_message (value, channel)
Send Pitch-Bend message to device

Parameters:

  • value: (Number) the pitch-bend value
  • channel: (Number) the MIDI channel
MidiDevice:send_sysex_message (...)
Send sysex message to device (adding the initial 0xF0 and 0xF7 values)

Parameters:

  • ...: (vararg) values to send, e.g. 0x47, 0x7F, 0x7B,...
MidiDevice:sysex_callback (message)
Invoked when we receive sysex data from the device

Parameters:

  • message: (Table/MIDIMessage)

Valid XHTML 1.0!