main site sponsors

Logic Pro X Scripter – An Introduction

the scripter MIDI FX plugin in Logic Pro X

The Logic Pro X Scripter Plugin seems to have been a little bit overlooked. Unlike the other new MIDI FX plugins, it does not have a shiny and polished GUI. Having a look at its inside world – the script editor – probably makes most users feel that to start programming scripts with Scripter will be a daunting task, and stop them from digging deeper. But even if you have no idea about programming, you can do some basic things with Scripter quite easily.

Logic Pro X Scripter – An Introduction

The Scripter API (Application Programming Interface) is object oriented and works with Javascript, so no C with pointers here. Every MIDI event is made available as an abstract object, which is brought to you for further inspection and manipulation through the function HandleMIDI(). If you include this function in your script, Logic Pro X will call it every time a MIDI event is sent to the channel that the Scripter plugin is running in. It will send this MIDI data inside of the event object as the argument of the function, here (event):


function HandleMIDI(event) {

}

This function acts like the middleman between the MIDI input and output of your channel. So if you add it like this to your script, there will be no output, because until now the function has been empty and does not do anything. To just pass the event through Scripter, you’ll have to add event.send() to the function. This calls the function send() and the received event will be sent to the MIDI output unchanged:


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

You can now access its MIDI parameters that are stored inside of the event object, for example note pitch, note velocity, controller number, value and so on. So if you want to simply transpose your notes, your function would look like this:


function HandleMIDI(event) {
event.pitch += 7;
event.send();
}

You should add a conditional if-statement to your code that limits the processing to NoteOn and NoteOff messages:


function HandleMIDI(event) {
if( event instanceof Note == true ) {
event.pitch += 7;
event.send();
}
}

Sofar this could have been done with Transpose in the Region Inspector, you would not need Scripter for this. But if you just change the code a little bit, it will become more interesting already:


function HandleMIDI(event) {
if( event instanceof Note == true ) {
event.send();
event.pitch += 7;
event.send();
}
}

So what happens here ? First, the original note event is sent unchanged. Then the pitch of the same event object – which is still in memory – is transposed and sent again. So when a note is played, the original note will be played together with the new interval note.

Now that you are familar with the if-statement already, you could add a velocity limiter:


function HandleMIDI(event) {
if( event instanceof Note == true ) {
if(event.velocity > 80){
event.velocity = 80;
}
event.send();
event.pitch += 7;
event.send();
}
}

How does that translate to human language ? The new if-statement has been added inside of the first if-statement. So it will be executed only, if the MIDI event is a note. If then the note’s velocity is higher than 80, which is evaluated by the operator >, the velocity parameter of the event will be set to 80.

To complete the code an additional else-statement at the end assures that all other events like control changes, program changes, etc. will be passed through without processing:


function HandleMIDI(event) {
if( event instanceof Note == true ) {
if(event.velocity > 80){
event.velocity = 80;
}
event.send();
event.pitch += 7;
event.send();
}
else {
event.send();
}
}

Hopefully this introduction gave you some idea what is possible with Logic X Scripter.

If you are a VSL Vienna Symphonic EXS24 Library User, have a look at the the 3R Audio VSL Performance Tools. They are all done with the Logic Pro X Scripter and give you back the full functionality of the legacy VSL performance tools in 64bit with Logic Pro X.

Related Posts:

Tags: ,

  • MMarx

    I just was messing around with the midi effects today and came across Scripter! Freaking amazing! Thanks for the article. Just another case of RTFM.

  • John Miller

    Question: is there a way to set breakpoints in the script editor?

  • Blanc

    Can you handle the Score Meta data in Scripter

Follow Logic Pro Expert