apricotandpearjam Posted September 18, 2023 Share Posted September 18, 2023 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! Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted September 18, 2023 Share Posted September 18, 2023 This is something you could script in Scripter: function HandleMIDI(event) { if(event instanceof NoteOn) { if (event.pitch >= 36 && event.pitch <= 51 || event.pitch >= 65 && event.pitch <= 98) { event.send(); } } else event.send(); } 1 Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted September 18, 2023 Share Posted September 18, 2023 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} ]; 2 Quote Link to comment Share on other sites More sharing options...
apricotandpearjam Posted September 19, 2023 Author Share Posted September 19, 2023 thankyou so much for this. its incredibly helpful. 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? cheers 🙂 1 Quote Link to comment Share on other sites More sharing options...
apricotandpearjam Posted September 19, 2023 Author Share Posted September 19, 2023 cant seem to get it working. for some reason when i set the two key ranges its allowing some through that should get through and stops some that should come through. have a look at this screen recording: https://www.dropbox.com/t/FAC8cJ2NLzLIBllC Quote Link to comment Share on other sites More sharing options...
Solution David Nahmani Posted September 19, 2023 Solution Share Posted September 19, 2023 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. Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted September 20, 2023 Share Posted September 20, 2023 @apricotandpearjam Did you get a chance to try my new script? It should work, and you now see note names: Let me know... and I'll move this thread to the Scripter forum later. 🙂 1 Quote Link to comment Share on other sites More sharing options...
polanoid Posted September 20, 2023 Share Posted September 20, 2023 FWIW script works perfectly here. Attaching a Logic project that incorporates it. Note Ranges Scripter.logicx.zip 1 Quote Link to comment Share on other sites More sharing options...
apricotandpearjam Posted September 20, 2023 Author Share Posted September 20, 2023 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: 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. Quote Link to comment Share on other sites More sharing options...
polanoid Posted September 20, 2023 Share Posted September 20, 2023 3 minutes ago, apricotandpearjam said: the only improvement i would ask for is 3 pitch ranges and the ability to switch them on and off. Come on, you know how to do copy and paste don't you 😉 ? jk I know it's not that simple, so here's the three range version. Note Ranges Scripter 2.logicx.zip Quote Link to comment Share on other sites More sharing options...
apricotandpearjam Posted September 20, 2023 Author Share Posted September 20, 2023 that's great thanks and yea sorry code looks like a jungle to me so i would have no idea what bit to copy and paste 😉 do u know how i could add something to this which would activate / de-activate each band? Quote Link to comment Share on other sites More sharing options...
polanoid Posted September 20, 2023 Share Posted September 20, 2023 2 minutes ago, apricotandpearjam said: sorry code looks like a jungle to me Fair enough! Version with switches: Note Ranges Scripter.logicx.zip Quote Link to comment Share on other sites More sharing options...
polanoid Posted September 20, 2023 Share Posted September 20, 2023 Seems I copy & pasted a bit too quickly, here's a cleaner version Note Ranges Scripter.logicx.zip 1 Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted September 21, 2023 Share Posted September 21, 2023 Thanks @polanoid for expanding on this script! Much appreciated. I'm moving this thread to the Scripter forum so we know where to find it. 🙂 1 Quote Link to comment Share on other sites More sharing options...
polanoid Posted September 21, 2023 Share Posted September 21, 2023 You're welcome! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.