Wednesday, July 9, 2008

Installing Timidity and creating bash script to play MIDI files in GUI mode

Info from following URLs:
http://forum.eeeuser.com/viewtopic.php?id=3550

Timidity is a software MIDI synthesizer. The Asus Eee PC 701's soundcard does not have a hardware MIDI synthesizer, hence the need for this. Timidity basically converts MIDI files to WAV files real-time. You will need FreePats also, which is a set of sound fonts, for Timidity to use. To install both, press Ctrl-Alt-T to open the terminal console and type the following 2 commands:

sudo apt-get install timidity
sudo apt-get install freepats

Timidity is a console player, ie. it runs from command line. To run it in GUI, you can type "timidity -ia" at the command line (some websites suggest -ig but my Eee PC doesn't seem to have the gtk libraries required). The following steps show how to create a batch/bash file so that you can use it as a shortcut to associate with MIDI files via kcontrol or put under the Favorites tab. We will put the bash script in /usr/bin as it is in the default $PATH.

  1. Press Ctrl-Alt-T to open the terminal console.

  2. Type "sudo nano /usr/bin/timidity-gui" to create a new bash script file.

  3. Type the following:

    #!/bin/bash
    nohup timidity -iatv $@

  4. (Just some explanation: $@ allows the bash file to take in commandline arguments and pass them in. Without it, no files can be passed in to play. Without nohup, the program will close when you close the shell window that you ran it from. -iatv sets the interface to XAW interface, traces the playing via a virtual keyboard and shows more verbose info)

  5. Press Ctrl-O to save and Ctrl-X to exit.

  6. Set the correct permissions so that it can be executed. Type
    "sudo chmod 755 /usr/bin/timidity-gui"

  7. If you want to associate the file, you can type "sudo kcontrol" at the command line and go to File Manager -> File Associations. Alternatively, double-click on a MIDI file and specify timidity-gui when asked for the application.

(^ v ^)

No comments: