FINALLY! SOME UPDATES! This website is being reconstructed. Some content will go away soon. If you want to see my new stuff, visit my github:

September 9, 2012

Timidity and The Slayers

A long long time ago when I was just a kid with a keyboard and a GeoCities account, I must admit that I participated in one of the many web page faux pas: Using MIDI Music in the background.

Today I know better than to do that with a website, but something happened this weekend. I rediscovered the song that was part of that website. Thanks to Netflix, over the past few days I was watching this old anime called The Slayers. My boredom had reignited a memory this morning when I got to the second season of the series titled Slayers Next. The song "Give a Reason" by Megumi Hayashibara (who for those anime geeks may know her as the Japanese voice actress for the lovely Faye Valentine from Cowboy Bebop which to this day is still popular here in the United States) was one of three MIDI files that I used on my very first website back in 1999. The other two songs, in MIDI format were "Pardon Me" by Incubus and "The Perfect Drug" by Nine Inch Nails.

So what makes this post relevant to a computer programming sense? We'll for starters, if you try playing Midi Files in Chrome, you will get a message saying "Could not load the VLC Multimedia Plugin (compatible Totem 3.0.1)". But why would you want to use VLC (or Totem for that matter) for playing a MIDI file?

At this time, I can't think of how to use today's hack the same way that Revision 3 did to get Festival working. (I mentioned something about that last month, just to let you know.) Perhaps some Internet Detective work will help. On the other hand, there isn't a whole lot of interest so just for the nostalgia, we'll settle on playing MIDI files in the command line.

You will need to have two packages installed: You are going to need the ALSA Utilities Package (alsa-utils) and Timidity++ (timdity). Fortunately for me, these packages are available in the Ubuntu Software Center. Of course using the following command line would be much better.

sudo apt-get install alsa-utils timidity

The ALSA Utilities package contains a program called aplaymidi. If you do not install the timidity package with it, you won't have the port you need to play MIDI files in the command line.

$ aplaymidi -l
Port    Client name                      Port name
14:0    Midi Through                     Midi Through Port-0
$ aplaymidi -p 14:0 next_give_a_reason_1.mid 

You will hear nothing! May as well type CTRL+C.

aplaymidi requires a port to play the MIDI file. timidity adds a few more ports that allows you to play music on your computer rather than through a MIDI sequencer device which is more than likely what 14:0 is the port for. Typing aplaymidi -l lists the available devices ALSA can use to play the MIDI file. It should also be noted that timdity runs as a daemon, so it runs in the background.

$ aplaymidi -l
Port    Client name                      Port name
14:0    Midi Through                     Midi Through Port-0
128:0   TiMidity                         TiMidity port 0
128:1   TiMidity                         TiMidity port 1
128:2   TiMidity                         TiMidity port 2
128:3   TiMidity                         TiMidity port 3
$ aplaymidi -p 128:0 next_give_a_reason_1.mid 

Ahhhh! Music to my 16-bit ears!

So that's one more thing you can do on the command line. Perhaps you use it to add some MIDI Music to an old-school side scrolling video game you can write. Or maybe show it off at some Demoscene event.

Either way, I'm happy with the results. And even happier to be reunited with this old song.


Under Construction