Note Hold (legato) for Logic Scripter as well as note filter

VST, AU, AAX, CLAP, etc. Plugin Virtual Effects Discussion
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi, I'm looking for a script to make logic pro x hold notes one at a time. for example I press the note C, even briefly, but it'll hold until I press the note D, while shutting off note C. I don't want to build layers, just keep it legato monophonic, from note to note.

In addition, as a separate script or plug in, I'm looking for a way of selecting which notes are passed on to the software instruments, ie, only C1, but not C2 etc, or just a given octave. Like a filter. Thanks!

Post

For the note filter, this can be set by going to the track inspector and adjusting the 'Key Limit' setting.

As for the script, here's something you can try. When the script is switched on you'll only be able to play a single note at a time, which will sustain until the next note is pressed, which will then also sustain. There's a tick box for 'legato' which in this context slightly delays the 'note off' so that playing a new note will result in the legato style if the synth patch you're playing supports it.

Code: Select all

/*
Sustain a single note until another is pressed
*/

var previousPitch = -1;
var legato = 0;

var PluginParameters = [{name:"Legato", type:"checkbox", defaultValue:0}];

function ParameterChanged(param, value)
{
	value == 0 ? legato = 0 : legato = 50;
}


function HandleMIDI(event)
{	
	if (event instanceof NoteOn)
	{
		if(previousPitch > -1)
		{
			var off = new NoteOff();
			off.pitch = previousPitch;
			off.sendAfterMilliseconds(legato);	
		}
		
		previousPitch = event.pitch;
		event.send();
	}
}

Post

For anyone interested, here's an updated version with checkboxes to control both sustain and legato setting.

[Edited to fix strange behaviour]
[Edit 2 to fix another bug]
[Edit 3 to improve the handling of the checkboxes]

Code: Select all

/*
Force MIDI output to be monophonic with optional sustain and legato mode
*/

var previousPitch = -1;
var legato = 0;
var sustain = 0;

var PluginParameters = [
{name:"Sustain", type:"checkbox", defaultValue:0},
{name:"Legato", type:"checkbox", defaultValue:0}
];

function ParameterChanged(param, value)
{
	if (param == 0)
	{
		sustain = value;
		if(value == 0)
			sendOff(0);
		else
			previousPitch = -1;
	}
	if(param == 1) value == 0 ? legato = 0 : legato = 10;
}

function sendOff(delay)
{
	if(previousPitch > -1)
	{
		var off = new NoteOff();
		off.pitch = previousPitch;
		off.sendAfterMilliseconds(delay);	
		}
}

function HandleMIDI(event)
{	
	if(event instanceof NoteOn)
	{
		if(previousPitch != event.pitch)
		{
			sendOff(legato);
			event.send();
		}
			else
		{
			if((sustain == 1 && legato == 0) || sustain == 0) sendOff(0);
			if(legato == 0 || (sustain == 0 && legato > 0)) event.send();
		}

		previousPitch = event.pitch;
	}

	if(event instanceof NoteOff && !sustain)
	{
		if(event.pitch == previousPitch) event.send();
	}
}

Post Reply

Return to “Effects”