I found that getting started with MIDI wasn't quite plug-and-play on Linux. Having no musical background, and no exposure to MIDI terms, it took a few Sunday mornings to get that first note to play out of a USB midi keyboard controller I borrowed from a friend.
My setup:
- Ubuntu 8.04
- vanilla alsa-compatible sound card, no wavetable or any fancy synth / midi capabilities of it's own
- a Roland PCR-30 midi keyboard controller, which has no sound output of it's own
My goal:
- Hit a key on the keyboard, and have it play out through my soundcard
I started with the gui shell for fluidsynth called 'qsynth', so:
apt-get install fluidsynth qsynth
Since I don't have a wavetable or whatever it's called, I needed a 'sound font' to emulate one.
apt-get install fluid-soundfont-gm
I launched qsynth, and by default it wanted to speak to jackd; I've never had jackd working correctly, it always produces crackling sound for me, so I clicked on 'setup', and changed hte audio driver to ALSA.
At this point, I used 'pmidi' to play a midi file out through the qsynth/fluidsynth MIDI device. You can see it by doing:
$ pmidi -l Port Client name Port name 14:0 Midi Through Midi Through Port-0 128:0 FLUID Synth (13710) Synth input port (13710:0)
And so I played a song by doing:
$ pmidi -p 128:0 <midi file>
Hurray! Sound! I plugged in the MIDI keyboard controller at this point, and was also able to see it in the output of pmidi listing:
$ pmidi -l Port Client name Port name 14:0 Midi Through Midi Through Port-0 20:0 PCR PCR MIDI 20:1 PCR PCR 1 128:0 FLUID Synth (13710) Synth input port (13710:0)
So, I can see the midi keyboard controller, 20:0, and 20:1, and I can see a synthesizer, 128:0 -- now I wanted to connect the two together somehow. After some random searching, I saw a comment in a bug report about midi referring to 'aconnect', which is the 'ALSA sequencer connection manager', and had some example syntax: "aconnect 64:0 65:0".
That looked exactly like the sort of thing I wanted to do, and it appeared to see the devices I wanted to use:
$ aconnect --input
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 20: 'PCR' [type=kernel]
0 'PCR MIDI '
1 'PCR 1 '
2 'PCR 2 '
$ aconnect --output
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 20: 'PCR' [type=kernel]
0 'PCR MIDI '
1 'PCR 1 '
client 128: 'FLUID Synth (13710)' [type=user]
0 'Synth input port (13710:0)'
I first tried connecting 20:0 to 128:0, that produced no output. Then I tried 20:1 to 128:0:
$ aconnect 20:1 128:0
I hit a key, and thought I heard a 'tink'. Or was that something outside? I turned up the volume on my stereo a bit, and at last, I had sound. It was playing a trumpet, which seemed to be left over from the midi file I played earlier. So I restarted qsynth, and reconnected the devices using aconnect, and it defaulted back to a piano.
References:
* Getting Started with MIDI on Linux, a fellow in the same boat as me * Free MIDI music, handy for testing: http://www.mididb.com/
![[ home ]](/images/ivory.png)