Ploki Posted August 21, 2021 Share Posted August 21, 2021 credit goes to for the original script: https://gist.github.com/edrd-f/f61f701cd3fdbd7e60cd8a0c9912a8a0 I just modified it so it passes all events through and adds a CC4 with alternating 0 and 127 to every other beat. Makes it easy with modifier to assign plugin parameters for i.e. alternating autopan. (this was my case, to control pan knob of microtonic of hihat) var notesOn = []; function isNotePlaying(event) { for (var i = 0; i < notesOn.length; i++) { if (notesOn[i] && notesOn[i].pitch == event.pitch) { return i; } } return false; } function sendNoteAlt(event) { var noteOffEvent = new NoteOn(); noteOffEvent.pitch = event.pitch; noteOffEvent.channel = event.channel; noteOffEvent.velocity = event.velocity; noteOffEvent.send(); } function sendCC(event) { var sendCC = new ControlChange(); sendCC.number = 4; sendCC.channel = event.channel; sendCC.value = 0; sendCC.send(); } function sendCCAlt(event) { var sendCCAlt = new ControlChange(); sendCCAlt.number = 4; sendCCAlt.channel = event.channel; sendCCAlt.value = 127; sendCCAlt.send(); } function HandleMIDI(event) { //event.trace(); if (event instanceof NoteOn) { var noteIndex = isNotePlaying(event) if (typeof noteIndex == 'number') { delete notesOn[noteIndex]; sendNoteAlt(event); sendCC(event); } else { notesOn.push(event); event.send(); sendCCAlt(event); } return; } if (event instanceof NoteOff) { return; } event.send(); } 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.