@aeva @mcc okay, I attempted to read the ALSA documentation, and there is indeed a facility to queue MIDI messages. But I don't understand it. It seems to be oriented towards playing back MIDI files.
Writing your own event list structure avoids all this stuff, but then you have to maintain it yourself. So I dunno.
Mostly I just use RtMidi in C++, which wraps everything in a simple, but limited, cross-platform API.