Scripter HandleMIDI function in Logic Pro for Mac

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 in order to process incoming MIDI events. If you don’t 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.

Load the corresponding Tutorial setting to view the script in the Script Editor. This will help you to understand the syntax structure and layout of code and comments. See Use the Script Editor.

Tutorial script 1: Simple Pass Through

Pass MIDI events through the plug-in.

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

Tutorial script 2: Trace Events

Log events to the plug-in console and don’t send them anywhere.

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

Tutorial script 3: Transpose and Delay

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

Text following /* shows comments that explain the JavaScript code.

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

Tutorial script 4: Detune Note Pitch

Tune all note on events up or down by cent (1/100 of a semitone) values. The range is −100 to +100 cents.

function HandleMIDI(event) {if (event instanceof NoteOn) { /* if it's a note on */event.detune = GetParameter("Detune") /* retrieve detune parameter value from var PluginParameters */}event.send(); /* send detune value */}var PluginParameters = [{name:"Detune", type:"lin", numberOfSteps:200, minValue:-100.0, maxValue: 100.0, defaultValue:0}];/* create a linear parameter called "Detune" with a range of -100 to 100, and a default value of 0 */

Download the guides:

Logic Pro User Guide: PDF

Logic Pro Instruments: PDF

Logic Pro Effects: PDF

Control Surfaces Support Guide: PDF

Morty Proxy This is a proxified and sanitized view of the page, visit original site.
Helpful?
Character limit: 250
Maximum character limit is 250.
Thanks for your feedback.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.