@Morphoice The solution I used was to keep track of all note on events, then if you ever receive two note ons in a row on the same note you know you've received some illegal MIDI.
It's pretty easy if on noteOn you check and store the event ID to an array (or MIDIlist I suppose) like
onNoteOn {
if (events[Message.getNoteNumber()]){
Console.print(You've just received some illegal MIDI!);
} else {
events[Message.getNoteNumber()] = Message.getEventId();
}
}
onRelease {
events[Message.getNoteNumber()] = undefined;
}
How you handle the lawbreakers is up to you, but at a minimum it's best to stop everything on that note, as this situation breaks the assumption that every note on will have a corresponding note off.
In my case I'm using artificial events, so stopping them all is easy. I don't actually know how you'd go about stopping the normal events.
Give Synth.allNotesOff() a try, I know that doesn't affect notes with a timestamp in the future but I assume it works on stuck regular events.
It would be nice if we got this built in similar to setfixnoteonafternoteoff