Sustain Pedal for Organ
I'm trying an organ which like many does not have a sustain pedal so it ignores CC64 messages. I have therefore tried to using the scripter to step in and suppress NoteOff messages when the pedal i pushed and then to send and allNotesOff when the pedal is released. The suppression works but the notes stay on after the pedal is released. Script is below. Can anyone advise why this is not working? Thanks for any help.
var pedal = 0;
//------------------------------------------------------------------------------
function HandleMIDI(e) {
if (e instanceof ControlChange && e.number == 64 && e.value > 63)
{
pedal = 1;
}
else if (e instanceof ControlChange && e.number == 64 && e.value < 64)
{
pedal = 0;
MIDI.allNotesOff();
}
else if (pedal == 1 && e instanceof NoteOff)
{
}
else
{
e.send();
}
}