Jump to content

Muting Notes When A Note Is Repeating

Recommended Posts

I've got a working version of a script that can randomly change notes and also that can repeat notes. Here's the rub, in a drum loop if I set a drum to repeat itself x times, one thing I've noticed that the repeats will play along with the same drum happening in the loop at its original time (if the repeats overlap the same drum). Thus, I'm curious how to keep track of what note(s) are currently repeating and to stop them from playing in the main loop while they're in their repeating phase.


Anyone have a means on how to explain that for a script? An array variable? How would I keep track? and once its done repeating, allow the drum play again in the loop normally? Thanks for any help. (Unheardofski?)

Link to comment
Share on other sites

Try something along these lines:


var noteList = new Array(128).fill(false);
// not 100% sure fill is implemented in the version Logic is using, if you get an exception do this instead:
var noteList = [];
for(let i = 127; i >= 0; i--){

function toggleBool(v) {
   return !v;

//in HandleMIDI function add something like this (apart from existing code but removing the existing e.send() ), adapted to your needs
function HandleMIDI(e) {
   if ((e instanceof NoteOn && !noteList[e.pitch]) ||
       (e instanceof NoteOff && noteList[e.pitch])) {
       noteList[e.pitch] = toggleBool(noteList[e.pitch]);

Link to comment
Share on other sites

  • 2 weeks later...

I'm still getting some flamming, would that be due to my using "e.sendAfterBeats" for the repeats? That's what I'm attempting to avoid, two of the same drum playing when I'm repeating & possibly randomly transposing.


After testing a little further, I find its only when I'm using some random transposing. Need to hunt down why the random transposing causes that.

Link to comment
Share on other sites

After moving where the repeats happen, I pretty much got the flamming to stop. There's still an occasional flam with the Kick and the Hi Hats. I'm still trying to suss it out. My guess is when a kick is triggered by either of the two notes that trigger a kick happen at the same time. As for the Hi Hat, that one is more confusing since the Logic Hi Hats should automatically not flam if two of their same ones trigger at the same time.


I think my next little piece of code should be checking if a certain note is playing and has more than one trigger, to not trigger it? What do you think Unheardofski?

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.

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