That worked beautifully, thank you. Now a random church in rural Kentucky has you to thank for the bit of Christmas magic that'll add to the sound.
For anyone who needs it, here's the script with Cap's modification for highest note. I kept the name "bassnote" to make the change easiest.
// Script start
var BassNoteNumber = 1;
var NoteIsOn = 0;
function SwitchNote(NoteNumber, Velo, state)
{
if(Velo == 0)
return state;
if(state == 0)
{
var on = new NoteOn;
on.pitch = NoteNumber;
on.velocity = Velo;
on.send();
}
else
{
var off = new NoteOff;
off.pitch = NoteNumber;
off.velocity = Velo;
off.send();
}
state = 1 - state;
return state;
}
function Reset()
{
if(NoteIsOn == 1)
NoteIsOn = SwitchNote(BassNoteNumber, 1, NoteIsOn);
BassNoteNumber = 1;
}
function HandleMIDI(event)
{
if(event instanceof NoteOn)
{
var Pitch = event.pitch;
if(Pitch > BassNoteNumber)
{
if(NoteIsOn == 1)
NoteIsOn = SwitchNote(BassNoteNumber, 1, NoteIsOn); // switch old note off
BassNoteNumber = Pitch;
NoteIsOn = SwitchNote(BassNoteNumber, event.velocity, NoteIsOn); // switch new Note on
}
}
else
if(event instanceof NoteOff)
{
var Pitch = event.pitch;
if(Pitch == BassNoteNumber)
{
if(NoteIsOn == 1)
NoteIsOn = SwitchNote(BassNoteNumber, 1, NoteIsOn); // switch old note off
BassNoteNumber = 1;
}
}
else
event.send();
}
// script end