HandleMIDI function

The HandleMIDI() function lets you process MIDI events that the plug-in receives. HandleMIDI is called each time a MIDI event is received by the plug-in and is required to process incoming MIDI events. If you do not implement the HandleMIDI function, events pass through the plug-in unaffected.

HandleMIDI is called with one argument, which is a JavaScript object that represents the incoming MIDI event. HandleMIDI and JavaScript Event object use is shown in the examples.

Code example 1

Pass MIDI events through the plug-in.

function HandleMIDI(event) {event.send();}

Code example 2

Log events to the plug-in console and do not send them anywhere.

function HandleMIDI(event) {event.trace();}

Code example 3

Repeat notes up one octave with 100ms delay and pass all other events through.

Text following “//” are comments.

function HandleMIDI(event) {event.send(); // send original eventif (event instanceof Note) { // if it is a noteevent.pitch += 12; // transpose up one octaveevent.sendAfterMilliseconds(100); // send after delay }}