logoalt Hacker News

catapartlast Friday at 6:22 PM2 repliesview on HN

Just a quick compatibility issue: for some reason, my midi board triggers a key input both when I press it down, and when I let it go. I'm assuming that it might just be something wrong with my board, but I did want to let you know in case there might be some nuance you haven't considered with respect to the midi commands. I know my first crack at it didn't distinguish between note-on and note-off commands, for instance.


Replies

ta2112last Friday at 6:49 PM

I can add a bit of information to what might be behind this bug.

In MIDI, there are NOTE_ON and NOTE_OFF events, for when you press and release each key. The NOTE_ON has pitch and velocity parameters. The NOTE_OFF just has pitch parameter (maybe it has velocity as well I can't quite remember, it's off the point). So if you push middle C, it might look like this:

NOTE_ON 60 (middle C) 98 (velocity), NOTE_OFF 60

Some keyboards never send NOTE_OFF events, instead they send NOTE_ON with velocity 0. On these keyboards, pressing middle C looks like this:

NOTE_ON 60 98, NOTE_ON 60 0

Both are valid MIDI streams, and all stream processors should react appropriately to both. This app likely does not correctly map zero velocity NOTE_ON events to NOTE_OFF with the same pitch.

vunderbalast Friday at 8:33 PM

Hey catapart,

Thanks for the feedback. Oof that's weird. Maybe I'm triggering some kind of odd aftertouch?

EDIT: Just saw ta2112's note. That's super helpful I'm definitely only responding to standard MIDI NOTE_ON and NOTE_OFF messages.

I'll try to get this fixed this evening.

show 1 reply