A midi node is automatically created at application level (/ITL/midi). Before using the MIDI features, the midi node must be explicitly initialised using the init message. On success, the ready event is triggered, otherwise an error event is triggered.
/ITL/midi watch ready ( do something to use the MIDI interface ); /ITL/midi watch error ( do something else ); /ITL/midi init;
MIDI is supported using a specific event that you can configure using the watch message. Before using MIDI, you should check that your browser is supporting the Web MIDI API.
A filter is used to select the MIDI messages that will trigger the event.
- an empty filter can be used to stop watching MIDI input
- '*' denotes any MIDI message (no filter at all)
- chan: an optional channel number may be used to select only the MIDI messages on a given MIDI channel
- midikey: is used to select key on/off messages according to their values and to an optional velocity.
- prog: is used to select program change messages. A program change number is expected as next argument.
- ctrl: is used to select control change messages. A control change number is expected as next argument.
Example Accept all MIDI messages that are on channel 0
/ITL/scene/obj watch midi chan 0 (inscore messages list);
A MIDI key is either keyon or keyoff. It may be followed by an optional velocity selector.
A MIDI value is either literal values or a range of values.
Literal values are:
- 1: a single value,
- 2: a list of space separated values enclosed in brackets,
All the values must be in the MIDI data range (0-127).
Example Accepting MIDI key on messages for 3 specific pitches.
/ITL/scene/obj watch midi keyon [60 62 64] (inscore messages list);
Range may be used when a value is within the specified range, or enters or leaves the range.
- 1: trigger the event when the value enters the range.
- 2: trigger the event when the value leaves the range.
- 3: trigger the event when the value is within the range.
Example Accepting keyon MIDI messages only when entering and leaving the range 60 - 67;
/ITL/scene/obj watch midi keyon '[60-67]' (inscore messages list); /ITL/scene/obj watch midi keyon ']60-67[' (inscore messages list);
MIDI verbose mode
In order to facilitate the detection of messages sent by a MIDI interface, a 'verbose' mode allows incoming messages to be displayed on the browser console. To enable or disable verbose mode, a specific message must be sent to the /ITL/midi object:
The parameter is a numerical value that controls which MIDI events are displayed:
- 0: disable the verbose mode
- 1: displays the channel MIDI events (Real-time and system exclusive events are filtered out).
- 2: displays all the MIDI events
/ITL/midi verbose 1;
Activates the MIDI verbose mode.