TIMIDITY

TiMidity is a MIDI-to-WAV rendering engine that uses Gravis Ultrasound PAT-format soundfiles or SF2-format soundfonts as its sound sources. MIDI note events are translated to audio data and the output may be rendered to a file or as a realtime audio stream. The program can be run from the console or xterm prompt, and it can be compiled for graphic control interfaces with a variety of toolkits (Gtk, Qt, Motif, Tcl/Tk, XAW, etc.).

When run from the command prompt TiMidity provides numerous rendering and playback options, far too many to explore here. For our exercises we'll use only a few of those options, but the reader is advised to see TiMidity's man page ('man timidity' at the prompt) for a full description of the program's various command-line enhancements.

USING TIMIDITY

Because TiMidity is a straightforward application we'll simply look at some of its most typical invocations. The following examples are all in command-line syntax: TiMidity's GUIs are quite helpful but they do not support the full range of available options.

To use TiMidity in its simplest form type the following command string at a console or terminal window prompt :

	timidity foo.mid
To launch TiMidity with a Motif GUI type this command :

	timidity -im foo.mid
To start TiMidity with its Gtk interface, an alternate patch file, and a queue of MIDI files :

	timidity -ig -c my-sf2.cfg foo-0.mid foo-1.mid foo-2.mid
This command string launches TiMidity with a more complex set of options :

	timidity -igr -c my-sf2.cfg -EFreverb=1,33 -A 100 /home/dlphilp/midfiles/*.mid
and here is what those options do :

It gets better: TiMidity can also play MIDI files contained in archived files (i.e. *.zip or *.tar.gz files) and it can play files found at HTTP, FTP, or USEnet newsgroup URLs. The next two examples illustrate these abilities :

	timidity 'my-archive.tar.gz#foo.mid'

	timidity http://www.bright.net/~dlphilp/midfiles/foo.mid
The first command will extract and play only the file named foo.mid contained in the archive file. The second command will render the MIDI file located at the indicated URL. Very simple, yes ? With the examples here and the man page you should now be able to customize your own TiMidity commands.

Although TiMidity is best known as a MIDI file player it will also render files in the standard module tracker MOD format. In addition to common MIDI and MOD files TiMidity will render a few other uncommon formats such as KAR and WRD files. These are karaoke file formats that include lyrics dutifully displayed by TiMidity during realtime performance. This is good news for Marco Trevisani and all other Linux karaoke specialists...

ADVANCED TIMIDITY

Obviously TiMidity can be employed as a useful helper application, particularly as a highly configurable MIDI playback engine. In the AGNULA documentation for Common Music I have described how TiMidity fits into that environment. TiMidity is also employed by the UMP (Universal MIDI Plugin), a handy helper for Web browsers. The UMP will automatically appear when a MIDI file is found within a Web page, or you can invoke it by clicking on a MIDI file's link. The UMP provides only a few simple playback controls but it is a handy browser plugin that in true UNIX fashion does one job and does it well.

One more aspect of TiMidity deserves mention here. The program can be launched as an ALSA sequencer client providing softsynth services to applications that otherwise might not be able to access a decent sound source (a common situation on many laptops). We'll explore those services further in Chapter XX, but here's a quick look at a typical syntax for this feature :

	timidity -iA -B2,8 -Os -c /home/dlphilp/timidity-sf2.cfg -EFreverb=0 -EFchorus=0 &
This line sets up TiMidity with its ALSA interface (-iA), adjusts playback audio buffers (-B2,8), formats the output (-Os), reads my TiMidity-with-soundfonts configuration file, and turns off the reverb and chorus effects. As an ALSA client TiMidity's rendering engine is now available as a realtime software synthesizer for the MIDI output from programs such as Common Music or the TK-707 virtual drum machine. This example is more fully explained in the AGNULA documentation for the TK707 software so we'll leave it for now, but it should be clear from the example that TiMidity's ALSA interface is a powerful feature.

As I finish this tutorial I'm listening to TiMidity in its Tk GUI randomly playing a directory of orchestral and solo piano MIDI files via the Fluid General MIDI soundfont. At the same time I'm compiling the latest MusE MIDI sequencer, running Netscape, and writing this tutorial, all on a modest laptop with a PII 366 MHz CPU. TiMidity's performance is flawless.

ADDITIONAL EXERCISES