leponceau.org

Programming And Stuff, You Know The Thing…

Connecting Java programs to JACK/ALSA MIDI devices under Linux

Posted at — Sep 30, 2017

It’s relatively simple to connect Java programs to hardware MIDI ports like Roland UM-ONE. However, the advantage of modern computers is that A LOT can be done in software. And that’s where we are starting to have problems. Unless…

I finally found a way to connect Java programs to other MIDI applications like fluidsynth or LMMS under Linux.

The trick is simple: there is a kernel module called snd-virmidi providing a MIDI loopback interface that looks like a hardware MIDI device to Java:

modprobe snd-virmidi
echo snd-virmidi >> /etc/modules # load on boot

After that simply start qjackctl and, for example, qsynth, and connect the VirMIDI output ports to the synth’s input ports under ALSA MIDI tab and the synth’s audio output ports to the system input ports

There are also some synths like setBfree out there that use JACK MIDI. To connect to those beasts, simply install and run a2jmidid.

Here is some example code.