If you know you are one of nine in ten, then you might as well stop reading right here. This post is not for you. Stop reading here and return back to your Ogg Vorbis or mp3 player. But if you are somebody who has a bunch of midi files in your home directory and would like to be able to play them, read on.
My story is that I have some midi-files collected from various games that I played when I was younger. I also have a collection of music by Björn Lynne (aka Dr. Awesome) in midi format. Since I still don’t have a life a enjoy listening to these files from time to time, just for that nostalgic feeling.
I use timidity++ to play midi files. Here I will show you how to start using timidity. I won’t go into any details, but there’s always
man timidity for that.
First of all, you need to install timidity. On Debian, that is as simple as
aptitude install timidity. There are some extra packages, but they contain (graphical) front-ends, which I don’t need as well as integration with Emacs, which I don’t either use. If you are not on Debian, you will need to check with your operating system’s package manager. It’s likely you will find a timidity++ package for your operating system/distro, but even if you don’t you can just grab the source package and roll your own.
Getting timidity++ installed is not enough. You will need to get some soundfonts for timidity to use. These are basically collections of samples of various instruments. Without them you won’t hear much. As a matter of fact, you won’t hear anything at all.
There is a package in the Debian repository called freepats. If you do an
aptitude show timidity you will see that freepats is recommended by the timidity++ package. You can install freepats with
aptitude install freepats. You will soon notice that the sound quality is not the best however. The fact is that most of the quality sound fonts cost a lot of money. But we can get better quality than what freepats gives us.
Head over to this page and you will find two good-quality soundfonts, Unison and PersonalCopy. Unison is smaller, so it will take less time to download. It’s still good sound font, so you can download that first. If you still want higher quality then you can try PersonalCopy.
Both these files are compressed so you will need to unzipped them. For Unison, this would be
gunzip Unison.sf2.gz. You should of course place the uncompressed file in a good place, where good means a place of your own choice. I created a directory,
/usr/local/share/midi and copied the .sf2 file there, but it can be almost any location that feels right for you.
Next we need to make timidity++ aware of the soundfont. We do this by editing the file
/etc/timidity/timidity.cfg (as root). We need to add a line to this file. I have a soundfont file called
PC51f.sf2 located in
/usr/local/share/midi so I added this line to
You will of course need to adjust the line to suit your own set-up. While you are editing
/etc/timidity/timidity.cfg, you might as well want to look at some of the other configuration settings. Later, as you become more familiar with timidity++, you might want to start experimenting with some of these settings.
Now we are done. We can start playing. Let’s assume that we have a midi file called
~/midi/ultima-8/theme.mid. To play it, do
% timidity ~/midi/ultima-8/theme.mid
Timidity is also able to play all the midi files in a directory if you pass it a directory, or midi files stored in various types of compressed files. The manual page can tell you much more about that.
However, you may soon notice that the sound can stagger, especially when you perform something that is requires a bit of processing power. In that case, you can use timidity++ to convert the midi files to another format. I use the following to convert a file to Ogg Vorbis format.
timidity -Ov ~/midi/ultima-8/theme.mid
If you like, you can add an output file name, with the
-o option. If you don’t supply an output file, the name of the ogg will be the same as the original midi, but with the extension changed from .mid to .ogg.
Once you have your Ogg Vorbis files, you can play them with ogg123 or import them to your import them into you mpd database. Notice that converting your midi files to Ogg Vorbis is not going to magically make them sound better. All it will do is reduce the staggering. If you don’t hear any staggering when playing with timidity++, you might as well not bother with the conversion.
You also have other export options. Again,
man timidity is your friend.
If you are looking for some midi files to play, I’ll give you a few sites. But, your music taste might not be the same as mine, so you might not enjoy them. You can search the ‘Net and find thousands of midi files. I’m sure you may find something that you like.
1. Mysterious Sosaria: an old site that is still around. Contains music from the Ultima games. I happen to have been addicted to these games once upon a time, and I just love to listen to the music. It brings back memories of my brother and I sitting up all nights and playing.. *sigh*
2. Björn Lynne: In the Amiga world, this Norwegian musician was known as Dr. Awesome. I enjoy his music. I often listen to his collection while I’m coding.
A final note, timidity++ is not the only solution for playing midi files. One other application that you may hear about is FluidSynth. I’m sure this is a very good application, but the only time I tried it I found it to use even more CPU resources than timdity++. But it might also be an application worth checking out. I’ve stayed with timidity++ over the years because it does what I need.