Minding MIDI on Linux

If you use MIDI on Linux, perhaps you have the same frustrations I do:

  1. Plug in some controllers, use aconnect to connect them to some software. All good!
  2. Now I’m fiddiling about my set up - and I unplug and replug a controller. Maybe I’m tiding up the wires, or perhaps it was an accident, or even a too-loose USB connector (I’m looking at you, Boppad!)
  3. POOF! The previously set up connection is now lost… I have to find my terminal window and aconnect again… Or re-run my setup script, tearing down the system and restarting.
  4. :crying_cat_face:

Enter, amidiminder - a service that watches your ALSA MIDI ports and connections, and will re-establish them if the ports disconnect and later reconnect! Further, there is a rules file so that you can also have it automatically make connections the first time - based on device names or types.

For example, my rules file has:

# connect things to my looper app, bicycle 
bicycle:synths --> Circuit
bicycle:controllers <-- nanoKEY2
bicycle:controllers <--> FaderFox UC44

# use the launchpad as keyboard input to apps
Launchpad Pro --> .app

I just made the first public release, 0.7, which is billed as “early adopter testing”. I’ve used it in several live streamed performances over the last month, so I’d say it’s ready.

It is lacking a bit in documentation, but the executable supports the --help flag for command line options, and the default rules file documents the different forms rules can take.

The release has a built .deb package file for Raspberry Pi - but the code should easily compile on any Linux system. Lastly, if you are running Blokas’ excellent Patchbox distribution, you should disable amidiauto, since this is a superset of that.

Full project on github: https://github.com/mzero/amidiminder


@mzero Are you aware of https://github.com/SpotlightKid/jack-matchmaker
It’s for JACK, not ALSA, but does the same thing (plus audio connections) :slight_smile:


I didn’t know about jack-matchmaker - but then again, I don’t use jack.

1 Like

Very nice, creating this utility crossed my mind more than a few times. I’ll try it out.

There is also aj-snapshot that does alsa midi routing but I’m not sure it is still maintained?

I also wanted to thank you @mzero on the side for the great elk 3.0 software :slight_smile:


Thank you!! Excited see if this fixes my issue with ALSA and my teensy MIDI device.

Well that has me curious… what is your issue with ALSA and your teensy?

Well, I’m honestly not too sure it’s related to ALSA, but I created a custom Teensy MIDI device to control a standalone RasPi/Supercollider instrument, and it seems to be rather fickle about when it shows up in SuperCollider. I’ve been working headless so I haven’t dug super deep into diagnosing the issue, but I didn’t really know where to start troubleshooting so I’m hopeful that this can help.

Well - it is and it isn’t: Supercollider only “accounts” for the MIDI ports at the moment MIDIIn.connectAll() is called. So, you can only see the port if you cause that to happen in SuperCollider after your Teensy is connected.

What’s more - while Supercollider will see it - and connect it - if the Teensy disconnects and reconnects, Supercollider will not reconnect. This is exactly the problem that motivated me to create amidiminder: It will notice the original connection made by Supercollider - the subsequent disconnection, and then reconnection of the Teensy device – and remake the connection to Supercollider automatically.

In summary:

  • Run amidiminder as a service - no need to change the configuration.
  • Connect your Teensy MIDI device
  • Start Supercollider and run your script that uses the Teensy
  • Now you can unplug and replug the Teensy, and it’ll get reconnected to your Supercollider script.

Thanks for making this. I have it working great on the Pi. It’s currently keeping the MIDIFighter Twister and Blokas midihub paired, which is turning out to be a fun combo.

1 Like