Jump to content
We are live again!

Duplicate and transpose the lowest note in a chord down an octave


Recommended Posts

Hello,

I have been searching for a script that will duplicate the lowest note of a chord and transpose it down by 12 semitones, while also allowing the original chord to pass through.

During my search I found a script that does this using a threshold but if a chord is above or below that then it does't work properly. I have also found a script the isolates the lowest note from a chord. So I attempted to combine aspects of these two scripts unsuccessfully.

Does anyone know if a script exists that does this? Or could assist?

Thank you.

Edited by Camtas
Link to comment
Share on other sites

Posted (edited)

There seems to be a small issue.

 

 

When I use it with a synth patch with sustain it reverts back to its original note when the key is released resulting in a jump in pitch.

Is anyone able to advise how the script could be modified to keep the pitch after the key is released?

 

 

Thanks

 

var actBassNote;
var actTotNotes = [];

function HandleMIDI(e) {
 switch (true) {
 case (e instanceof Note):
 handleNotes(e);
 return;
 break;
 default:
 e.send();
 }
}

function handleNotes(e) {
 if (actBassNote && e.pitch > actBassNote.pitch) {
 if (e instanceof NoteOn) {
 actTotNotes.push(e);
 } else {
 for (var i = actTotNotes.length - 1; i >= 0; i--) {
 if (actTotNotes[i].pitch == e.pitch) {
 actTotNotes.splice(i, 1);
 }
 }
 }
 return;
 }

 if ((actBassNote && e instanceof NoteOn && e.pitch < actBassNote.pitch) || !actBassNote && e instanceof NoteOn) {
 if (actBassNote) {
 var off = new NoteOff(actBassNote);
 off.pitch < 128 ? off.send() : false;
 };
 actBassNote = e;
 e.send();
 return;
 }
 if (actBassNote && e.pitch == actBassNote.pitch && e instanceof NoteOff) {
 e.send();
 actBassNote = {
 pitch: 128
 };
 if (actTotNotes.length) {
 actTotNotes.forEach(function(c, i) {
 if (c.pitch < actBassNote.pitch) {
 actBassNote = c;
 actBassNote.i = i;
 }
 });
 actBassNote.send();
 actTotNotes.splice(actBassNote.i, 1);
 }
 }
}

 

Edited by Camtas
typo
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.

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.

 Share

×
×
  • Create New...