Playing MIDI files in Ubuntu

Ubuntu Hardy Heron does not seem to be able to play MIDI files out of the box. Still, the software and resources needed to do so are readily available and should not pose much of a challenge to set up.

Though there is more than one route to obtaining MIDI support on Ubuntu, the one that worked best for me was through a soft synth called Timidity++ (or just Timidity). Timidity is available from the Ubuntu software repository, and I downloaded and installed it with the Synaptic Package Manager. Having installed it, I was able to play MIDI files from the terminal by invoking Timidity and passing a file name as an argument:

$ timidity mysong.mid

By default, Timidity makes use of the Freepats MIDI sound bank which was already installed on my system. However, this sound bank is not complete and you will often notice that parts of a track you are playing are missing. Timidity supports SoundFonts and these can be used to plug in an alternate sound bank. I downloaded one called Unison (available freely on the web). Large SoundFont banks will come compressed in a proprietary format called sfArk. There is a Linux utility to decompress these files and I believe that it is free of charge, but since I had already installed the Windows version on my Vista partition, I used Wine to run it directly in Ubuntu. Once Unison was decompressed, I had to configure Timidity to use it instead of the Freepats sound bank. This can be done in /etc/timidity/timidity.cfg (notice I commented out the line that includes the Freepats configuration file):

#source /etc/timidity/freepats.cfg soundfont /path/to/Unison/Unison.SF2

That done, I was able to play MIDI files with all instruments sounding properly. There are other SoundFonts I'd like to try too - the quality can make a big difference to MIDI playback.

Invoking Timidity from the terminal isn't ideal, and there is a basic GUI available. I found it, however, awkward and very old fashioned, so discarded it. Another option is to install KMid (again available via Synaptic), which is a GUI designed for Karaoke use, which can easily be configured to use Timidity as its MIDI synth. However, on my system I found that playback through KMid was plagued by timing issues, so I have discarded that too and am sticking to the terminal for the time being.