Midi

Description

The Midi API provides the ability to connect Interface with musical instruments and other external or virtual devices via the MIDI protocol. For further information and examples, see the tutorial: Use MIDI to Control Your Environment.

Note: Only works on Windows.

Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts

Methods

Name Return Value Summary
allNotesOff None Turns off all notes on all connected MIDI devices.
blockMidiDevice None Blocks a MIDI device's input or output.
broadcastEnable None Enables or disables broadcasts to all unblocked devices.
listMidiDevices Array.<string> Gets a list of MIDI input or output devices.
playMidiNote None Plays a note on all connected devices.
resetDevices None Cleans up and rediscovers attached MIDI devices.
sendMidiMessage None Sends a MIDI message to a particular device.
sendRawDword None Sends a raw MIDI packet to a particular device.
thruModeEnable None Enables or disables repeating all incoming notes to all outputs. (Default is disabled.)
typeChanPressureEnable None Enables or disables channel pressure events.
typeControlChangeEnable None Enables or disables control change events.
typeNoteOffEnable None Enables or disables note off events.
typeNoteOnEnable None Enables or disables note on events.
typePitchBendEnable None Enables or disables pitch bend events.
typePolyKeyPressureEnable None Enables or disables poly key pressure events.
typeProgramChangeEnable None Enables or disables program change events.
typeSystemMessageEnable None Enables or disables system message events.
unblockMidiDevice None Unblocks a MIDI device's input or output.

Signals

Name Summary
midiMessage Triggered when a connected device sends an output.
midiNote Triggered when a connected device sends an output.

Deprecated: This signal is deprecated and will be removed. Use midiMessage instead.

midiReset Triggered when the system detects there was a reset such as when a device is plugged in or unplugged.

Type Definitions

MidiMessage
Type: object

A MIDI message.

Warning: The status property is NOT a MIDI status value.

Properties

Name Type Summary
device number Device number.
raw Midi.RawMidiMessage Raw MIDI message.
status number Channel + status. Legacy value.
channel number Channel: 116.
type number Status: Midi.MidiStatus; 815.
note number Note: 0127.
velocity number Note velocity: 0127. (0 means "note off".)
bend number Pitch bend: -81928191.
program number Program change: 0127.
MidiStatus
Type: number

A MIDI status value. The following MIDI status values are supported:

ValueDescription
8Note off.
9Note on.
10Polyphonic key pressure.
11Control change.
12Program change.
13Channel pressure.
14Pitch bend.
15System message.

RawMidiMessage
Type: number

An integer DWORD (unsigned 32 bit) message with bits having values as follows:

00000000 0vvvvvvv 0nnnnnnn 1sss cccc

Where:

The number in the first bit of each byte denotes whether it is a command (1) or data (0).

Method Details

(static) allNotesOff( )

Turns off all notes on all connected MIDI devices.

(static) blockMidiDevice( name, output )

Blocks a MIDI device's input or output.

Parameters

Name Type Description
name string The name of the MIDI device to block.
output boolean true to block the device's output, false to block its input.
(static) broadcastEnable( enable )

Enables or disables broadcasts to all unblocked devices.

Parameters

Name Type Description
enable boolean true to have "send" functions broadcast to all devices, false to have them send to specific output devices.
(static) listMidiDevices( output ) → {Array.<string>}
Returns: Array.<string>

Gets a list of MIDI input or output devices.

Parameters

Name Type Description
output boolean true to list output devices, false to list input devices.
(static) playMidiNote( status, note, velocity )

Plays a note on all connected devices.

Parameters

Name Type Description
status MidiStatus Note status.
note number Note number.
velocity number Note velocity. (0 means "note off".)
(static) resetDevices( )

Cleans up and rediscovers attached MIDI devices.

(static) sendMidiMessage( device, channel, type, note, velocity )

Sends a MIDI message to a particular device.

Parameters

Name Type Description
device number Integer device number.
channel number Integer channel number.
type Midi.MidiStatus Integer status value.
note number Note number.
velocity number Note velocity. (0 means "note off".)
(static) sendRawDword( device, raw )

Sends a raw MIDI packet to a particular device.

Parameters

Name Type Description
device number Integer device number.
raw Midi.RawMidiMessage Raw MIDI message.
(static) thruModeEnable( enable )

Enables or disables repeating all incoming notes to all outputs. (Default is disabled.)

Parameters

Name Type Description
enable boolean true to enable repeating all incoming notes to all output, false to disable.
(static) typeChanPressureEnable( enable )

Enables or disables channel pressure events.

Parameters

Name Type Description
enable boolean true to enable, false to disable.
(static) typeControlChangeEnable( enable )

Enables or disables control change events.

Parameters

Name Type Description
enable boolean true to enable, false to disable.
(static) typeNoteOffEnable( enable )

Enables or disables note off events.

Parameters

Name Type Description
enable boolean true to enable, false to disable.
(static) typeNoteOnEnable( enable )

Enables or disables note on events.

Parameters

Name Type Description
enable boolean true to enable, false to disable.
(static) typePitchBendEnable( enable )

Enables or disables pitch bend events.

Parameters

Name Type Description
enable boolean true to enable, false to disable.
(static) typePolyKeyPressureEnable( enable )

Enables or disables poly key pressure events.

Parameters

Name Type Description
enable boolean true to enable, false to disable.
(static) typeProgramChangeEnable( enable )

Enables or disables program change events.

Parameters

Name Type Description
enable boolean true to enable, false to disable.
(static) typeSystemMessageEnable( enable )

Enables or disables system message events.

Parameters

Name Type Description
enable boolean true to enable, false to disable.
(static) unblockMidiDevice( name-, output )

Unblocks a MIDI device's input or output.

Parameters

Name Type Description
name- string The name of the MIDI device to unblock.
output boolean true to unblock the device's output, false to unblock its input.

Signal Details

midiMessage( message )
Returns: Signal

Triggered when a connected device sends an output.

Parameters

Name Type Description
message Midi.MidiMessage The MIDI message.
midiNote( message )
Returns: Signal

Triggered when a connected device sends an output.

Deprecated: This signal is deprecated and will be removed. Use midiMessage instead.

Parameters

Name Type Description
message Midi.MidiMessage The MIDI message.
midiReset( )
Returns: Signal

Triggered when the system detects there was a reset such as when a device is plugged in or unplugged.