ALSA MIDI Sequencer as UDP service

`alsa-lib` is used to interface with the ALSA MIDI Sequencer, while `libuv` is used to build the UDP component

ALSA MIDI Sequencer as UDP service

My son is a musician, and I have written a few MIDI applications with Electron and the midi Node.js package for him over the last couple years.

But when I tried to update them recently — using a more recent version of Electron, or adding a web server to a MIDI application —, I ran into various issues, all known and documented already (such as changes in Electron with regards to integration of native libraries) but which would require to change modules.

I surveyed the existing MIDI packages in Node.js, noticing jazz-midi along the way, but although the Node.js part is available as source, it seemed that the very bottom of the stack were some pre-built .node binaries with no source code in sight.

I then surveyed the Python MIDI modules, and found that most of them were outdated (no Python3 support) and/or dating back a few years back.

A long story short, I started developing in my spare time over the last couple weeks a workable, future-proof solution that should work for most environments. The base project consists of an application written in C. alsa-lib is used to interface with the ALSA MIDI Sequencer, while libuv is used to build the UDP component; both should provide speedy delivery. This service will be coupled with language-side APIs (I'll target Node.js for now).

At this point the code is capable of exporting most useful ALSA Sequencer events to UDP (including note and controller events, port connections and disconnections, etc.), and to send (bytestream) MIDI messages into the Sequencer. This means it is able to interface with instruments and do transformations on streams.

(This is part 1 of a series of posts. Part 2 is here!)