Jump to content

Midi Script to force Last Note Priority?


Recommended Posts

I have several synths that are either high note or low note priority. I hate that. I just want last note. It seems like something Logic could handle to just send last note to the midi out so the synth itself doesn't need to bother. I tried the voice limiter object and it does work, but it doesn't retrigger a previously held note so you can't do rapid pivots and trills. 

 

It seems like there would be a simple midi script for this. 

 

Any ideas? 

Link to comment
Share on other sites

var hold = [];

function HandleMIDI(e) {
  var a = e instanceof NoteOn && e.velocity != 0;
  var b = e instanceof NoteOff;

  if (a) {

    switch (hold.length) {

      case 0:
        hold.push(e.pitch);
        e.send(), e.trace();
        break;

      case 1:
        if (hold[0] != e.pitch) {
          var noff = new NoteOff();
          noff.pitch = hold[0];
          noff.velocity = 0;
          noff.send(), noff.trace();
          hold.pop();
          e.send(), e.trace();
          hold.push(e.pitch);
          break;
        }
     }
  }
  
  if (b) {
    e.send(), e.trace();
    if (e.pitch == hold[0]) {
      hold.pop();
    }
  }

  if (!a && !b) {
    e.send(), e.trace();
  }

}

Edited by ski
Link to comment
Share on other sites

The above code gives you true last note priority. Instructions to install it below. If you want something that lets you hold a note and repeatedly play another so you can do trills, that would be a different ballgame. But see how this works for you for starters...

 

• Install a Scripter plugin

• Open the Scripter editor

• CMD+A and then hit Delete to get rid of everything

• Copy and paste the above code into the editor

• Click Run Script

Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...

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