Am I missing something or is Sustain pedal event wrongly handled in the code ? It seems that if we release the MIDI pedal while a MIDI keyboard key is still down, it will cut off the sound for that note anyway. And looking at the handleSustainPedal code seems to confirm that, unfortunately.