I think this code should probably only trigger for MIDI_NOTE_ON -- it was just an oversight that it didn't before.