Jump to content

Note Lock Script


OllieC
Go to solution Solved by David Nahmani,

Recommended Posts

Hello All,

I need to build a simple script that will filter all incoming notes to a single note which can be selected via a single fader. Unfortunately I have absolutely no scripting experience. The stock tutorial script (8. event modification) gets close but I couldn't quite figure out how to modify it to work properly.

Any help would be greatly appreciated!

Thanks

Link to comment
Share on other sites

Thanks David! I should have stated that the reason I'd prefer to do this via script is so that I can have the note names assigned to the slider which would then be reflected in my smart controls values. Hopefully one day we can create custom value tables for smart controls.. 

Link to comment
Share on other sites

  • Solution

I see! Ok then try this: 

var NOTES = MIDI._noteNames;

function HandleMIDI(e) {
  	if ((e instanceof NoteOn) || (e instanceof NoteOff)) {
    e.pitch = GetParameter('Output note pitch'); 
    e.send(); }
	else
		e.send();
}

var PluginParameters = [
	{	name:'Output note pitch', 
		type:'menu',
		valueStrings:NOTES,
		minValue:0, 
		maxValue:127, 
		numberOfSteps:127, 
		defaultValue:40},
];
  • Like 2
  • Love 1
Link to comment
Share on other sites

David great job whipping up a script.  So the only additional thing i might say is that this script is that if the sliders is moved while holding a note....there will be notes left hanging.

I don't have access to a mac right now, but so what I would think about doing is keeping a counter variable.  For each note On increment it, for each note off decrement it.  when the slider is moved, don't actually update the new pitch until the counter is back to zero.  something like that.  There could be some other elaborate approach perhaps...or just make sure not to be holding any notes while moving the slider. hehe

If LogicPro Ipad would only let me edit Scripter scripter I'd try something....but alas....

  • Like 2
Link to comment
Share on other sites

i don't have a mac now to test this, but something more or less like this, you might have to debug it since i am just typing it here blindly with no way to test it.

var NOTES = MIDI._noteNames;

var noteCount=0;
var currPitch=-1;
var nextPitch=-1;

function HandleMIDI(e) {

	if(noteCount==0) {
		if(nextPitch==-1) {
			nextPitch=GetParameter(0);
		}
		currPitch=nextPitch;
	}

	if(e instanceof NoteOn) {
		noteCount++;
		e.pitch = currPitch;
	}
	else if(e instanceof NoteOff || (e instanceof NoteOn && e.velocity < 1)) {
		noteCount--;
		e.pitch = currPitch;
	}

	e.send();
}

function ParameterChanged(arg, val) {
	nextPitch = val;
}

var PluginParameters = [
	{	name:'Output note pitch', 
		type:'menu',
		valueStrings:NOTES,
		minValue:0, 
		maxValue:127, 
		numberOfSteps:127, 
		defaultValue:40},
];

 

Edited by Dewdman42
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...