Jump to content

midi plugin - deactivate certain midi notes


Go to solution Solved by David Nahmani,

Recommended Posts

hi all. 

i know there is a key range in the inspector for each midi track but id like to know if there was a way of choosing which notes you allow through and which you don’t. 

for example i might need C-2 > G-3 but also B-4 > G-5. 

this is to prevent me from hitting notes which change certain things like keyswitches or custom settings which certain libraries have laid out on keys. 

thanks! 

Link to comment
Share on other sites

Ok here's a better version, along with an interface to dial in the min/max for both pitch ranges! 🙂 


function HandleMIDI(event) {
	if(event instanceof NoteOn) {
        if (event.pitch >= GetParameter('Range 1 Min Pitch') && event.pitch <= GetParameter('Range 1 Max Pitch') || event.pitch >= GetParameter('Range 2 Min Pitch') && event.pitch <= GetParameter('Range 2 Max Pitch')) {
            event.send();
        }
    } else event.send();
    event.trace();

}

var PluginParameters = [
	{	name:"Pitch Range 1",
		type:"text"},
	{	name:'Range 1 Min Pitch', type:'lin',
		minValue:0, maxValue:127, numberOfSteps:127, defaultValue:30},
	{	name:'Range 1 Max Pitch', type:'lin', 
		minValue:0, maxValue:127, numberOfSteps:127, defaultValue:45},
	{	name:"Pitch Range 2",
		type:"text"},
	{	name:'Range 2 Min Pitch', type:'lin',
		minValue:0, maxValue:127, numberOfSteps:127, defaultValue:68},
	{	name:'Range 2 Max Pitch', type:'lin', 
		minValue:0, maxValue:127, numberOfSteps:127, defaultValue:88}
];

Screen Shot 2023-09-18 at 4.01.38 PM.png

  • Like 2
Link to comment
Share on other sites

  • Solution
33 minutes ago, apricotandpearjam said:

is there any way of editing this so that the pitch is displayed as midi notes ie G2 / B#3 etc rather than a number?

Yes! Here you go: 

var NOTES = MIDI._noteNames;				//array of MIDI note names for menu items

function HandleMIDI(event) {
	if(event instanceof NoteOn) {
        if (event.pitch >= GetParameter('Range 1 Min Pitch') && event.pitch <= GetParameter('Range 1 Max Pitch') || event.pitch >= GetParameter('Range 2 Min Pitch') && event.pitch <= GetParameter('Range 2 Max Pitch')) {
            event.send();
        }
    } else event.send();
    event.trace();

}

var PluginParameters = [
	{	name:"Pitch Range 1",
		type:"text"},
	{	name:'Range 1 Min Pitch', 
		type:'menu',
		valueStrings:NOTES,
		minValue:0, 
		maxValue:127, 
		numberOfSteps:127, 
		defaultValue:40},
	{	name:'Range 1 Max Pitch',
		type:'menu', 
		valueStrings:NOTES,
		minValue:0, 
		maxValue:127, 
		numberOfSteps:127, 
		defaultValue:45},
	{	name:"Pitch Range 2",
		type:"text"},
	{	name:'Range 2 Min Pitch',
		type:'menu',
		valueStrings:NOTES,
		minValue:0,
		maxValue:127, 
		numberOfSteps:127, 
		defaultValue:68},
	{	name:'Range 2 Max Pitch',
		type:'menu',
		valueStrings:NOTES,
		minValue:0,
		maxValue:127,
		numberOfSteps:127,
		defaultValue:88}
];


 

22 minutes ago, apricotandpearjam said:

cant seem to get it working.

Seems to work as expected here? Try the new one and let me know. 

Link to comment
Share on other sites

42 minutes ago, David Nahmani said:

@apricotandpearjam Did you get a chance to try my new script? It should work, and you now see note names: 

Screen Shot 2023-09-20 at 9.59.00 AM.png

Let me know... and I'll move this thread to the Scripter forum later. 🙂 

this is absolutely amazing thankyou @David Nahmani.

the only improvement i would ask for is 3 pitch ranges and the ability to switch them on and off.

but other than that it works brilliantly.

 

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...