Setting up the hardware environment to support MIDI devices is relatively easy. in fact, most newer MIDI devices do not rely on the old sound card game port and adding a MIDI device is just like adding an external hard drive. The reason I had to resort to a dual sound card setup is because my MIDI keyboard (MK-4903) is more than ten years old and it only has a game port interface.As I mentioned earlier, the resources I could find on the Internet on Linux MIDI device support are few and far between. A couple of good ones I found are this one (Making Music) on Linux Magazine and this one (Getting Started with MIDI on Linux). Here I will show how to configure under Ubuntu 8.04.

Since my MIDI keyboard uses the game port interface on my Sound Blaster Live! sound card, there is no need to load any firmware. After the sound card is recognized by the system, you will find a /dev/midi device (for some reason, my midi device would change between /dev/midi and /dev/midi1 once a while, but this only happens when I access the midi device using jack). Without any additional software, you should be able to do a cat /dev/midi and see some "random" characters printed on the console whenever you press a key on the MIDI keyboard. Even without touching the MIDI keyboard, you should still see characters get printed in the console at a rate of 3 to 5 characters per second. Alternatively, you could use amidi –dump and when a key is pressed some hex values should be displayed.

After confirmed that the MIDI device is working properly, we can move on to setting up the software environment. Most of the aforementioned articles are concentrated on connecting to MIDI devices using ALSA. What I have found out though is that using OSS is much easier.

Various sources have suggested that connecting MIDI devices using ALSA have very low-latency (e.g. the time between when a key is pressed and the note is played) and thus is the preferred method. But for modern computers, this kind of latencies have rarely been a problem. There might be some difference in terms of latency between using ALSA and using OSS but they are not observable in my case.

To use OSS, all you need to do is to choose the correct option in qsynth:

qsynth setting 1

qsynth settings 1

qsynth settings 2

qsynth settings 2

If you have multiple sound cards configured like in my case, you can select from which sound card you want the sound to be outputted (e.g. /dev/audio or /dev/audio1 etc.). The sound does not have to be produced on the same card where the MIDI device is connected. In fact, using a single sound card as the output device might be the most attractive solution since otherwise you will need to have one pair of speakers connects to each of the soundcard output. In my case, the Sound Blaster Live! card is only used for it’s game port to connect with my MIDI keyboard.

After you have successfully restarted qsynth, you should be able to hear sound when you press on the MIDI keyboard and you should see the indicator on qsynth flashing, indicating that MIDI signal was received.


If you see activities from qsynth but there is no sound coming out then chances are that you have chosen the wrong sound card as the output device. Note that you will have to first load a Sound Font into qsynth, otherwise you will not hear any sound either. A few popular Sound Fonts can be downloaded from here.

MIDI Setup with ALSA requires a bit more work. First you need to start the jack daemon (jack -d alsa), or you could use the GUI Jack Control. Then you can start rosegarden. If you have timidity installed you you should be able to use timidity’s port (usually 128:0) as midi device port. If you are not sure, you could use pmidi -l to find out (this shows what my configuration looks like):

 Port     Client name                       Port name
 14:0     Midi Through                      Midi Through Port-0
 20:0     SBLive! Value [CT4780]            EMU10K1 MPU-401 (UART)
 21:0     Emu10k1 WaveTable                 Emu10k1 Port 0
 21:1     Emu10k1 WaveTable                 Emu10k1 Port 1
 21:2     Emu10k1 WaveTable                 Emu10k1 Port 2
 21:3     Emu10k1 WaveTable                 Emu10k1 Port 3
128:0     TiMidity                          TiMidity port 0
128:1     TiMidity                          TiMidity port 1
128:2     TiMidity                          TiMidity port 2
128:3     TiMidity                          TiMidity port 3

You can use either the Emu10k1 ports (21:x) or TiMidity ports (128:x) as output.

Since Sound Blaster Live! utlizates hardware based SoundFont, you must load appropriate SoundFont onto the board before you can hear any playback. Due to the on-board memory limitations, not all SoundFonts can be loaded onto Sound Blaster Live! Here is an 8MB version of the Creative Sound Font that you can use with Sound Blaster Live!. To load the sound font use the following command:

sfxload 8MBGMSFX.SF2 (assuming that the Sound Font is located in the current directory)

For more detailed MIDI setup using ALSA you can refer to the two articles I mentioned. What I have found is that the MIDI environment using jack is not always stable. For instance, I could instantiate the ALSA sound driver using jackd but not directly with jack GUI. And once a while jack would lock up. Another problem is that the MIDI device name seemed to change back and forth between /dev/midi and /dev/midi1 whenever I was using jack. This might be because the fact that I am using two sound cards though. Anyway, since the performance of using OSS turned out to be quite good I did not investigate the ALSA issue much further…

Be Sociable, Share!