This is a quick & dirty way to attach an Akai MPK mini 2 USB MIDI controller to Linux so the Linux machine can act as its synthesizer. This approach should work for any modern USB MIDI instrument.
I looked around on the web and, surprisingly, I didn't find any simple options for quickly starting Fluidsynth up and wiring it to a MIDI controller for simple keyboard usage. There are a few out there that involve using Qsynth which is cool but I didn't want a GUI for something relatively simple.
These are the basic steps. Where I use a port number, be sure to look at the aconnect -l
output on your machine to see what's right for your situation. The exact values used here probably won't work.
First, start up Fluidsynth in daemon mode. I chose to route it through Pulseaudio and take the latency hit for now because this is not my primary machine and it typically only gets used to play music sometimes.
[atobey@gadget ~]$ fluidsynth -m alsa_seq -a pulseaudio -s ff6.SF2
FluidSynth version 1.1.6
Copyright (C) 2000-2012 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.
fluidsynth: Using PulseAudio driver
Type 'help' for help topics.
> fluidsynth: warning: Failed to set thread to high priority
fluidsynth: warning: Failed to set thread to high priority
If you like, you can set that high priority by running chrt
in a different terminal. (You could run Fluidsynth as root but that's anathema to my working style).
sudo chrt --rr --all-tasks --pid 50 $(pidof fluidsynth)
With your USB MIDI device plugged in, list the MIDI devices available. Modern Linux machines should load the driver and present the instrument right away.
[atobey@gadget ~]$ aconnect -l
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 28: 'MPKmini2' [type=kernel,card=3]
0 'MPKmini2 MIDI 1 '
client 128: 'FLUID Synth (60137)' [type=user,pid=60137]
0 'Synth input port (60137:0)'
On my machine, the MPKmini2 input device is 28:0 and the synthesizer is 128:0 and I want events from the MPK Mini routed to Fluidsynth.
[atobey@gadget ~]$ aconnect 28:0 128:0
[atobey@gadget ~]$ aconnect -l
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 28: 'MPKmini2' [type=kernel,card=3]
0 'MPKmini2 MIDI 1 '
Connecting To: 128:0
client 128: 'FLUID Synth (60137)' [type=user,pid=60137]
0 'Synth input port (60137:0)'
Connected From: 28:0
And that's it! I now have sound from my keyboard. There's a little more latency than I like, but I'm pretty sure that's in Pulseaudio and I'll deal with that later.