OllieC Posted November 10, 2023 Share Posted November 10, 2023 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 Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted November 10, 2023 Share Posted November 10, 2023 You could use the Modifier for this. Set it that way and adjust the "Add" slider for the desired pitch : 1 Quote Link to comment Share on other sites More sharing options...
OllieC Posted November 10, 2023 Author Share Posted November 10, 2023 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.. Quote Link to comment Share on other sites More sharing options...
Solution David Nahmani Posted November 10, 2023 Solution Share Posted November 10, 2023 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}, ]; 2 1 Quote Link to comment Share on other sites More sharing options...
OllieC Posted November 10, 2023 Author Share Posted November 10, 2023 This is exactly what I was looking for. Thank you so much David! Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted November 10, 2023 Share Posted November 10, 2023 Great! Good to hear. You're welcome. 🙂 Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 10, 2023 Share Posted November 10, 2023 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.... 2 Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 10, 2023 Share Posted November 10, 2023 (edited) 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 November 10, 2023 by Dewdman42 3 Quote Link to comment Share on other sites More sharing options...
OllieC Posted November 10, 2023 Author Share Posted November 10, 2023 Thanks! I'm getting this message: Exception calling HandleMIDI() function: [JS Exception] ReferenceError: Can't find variable: NoteCount line:9 Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 10, 2023 Share Posted November 10, 2023 typo. try it now Quote Link to comment Share on other sites More sharing options...
OllieC Posted November 10, 2023 Author Share Posted November 10, 2023 Brilliant! Working great. I had just spotted the capital 'N' was causing the issue before you responded. Thank you so much 🙂 Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 10, 2023 Share Posted November 10, 2023 this is still kind of simplistic, it should prevent hanging notes, but if you try to slide the slider while actually holding any notes....it won't change the pitch until all currently held notes stop sustaining and then the slider value will take effect. 2 1 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.