Previous Next Contents

2. Playing Various Sound Formats

There are many kinds of sound formats (wav, MIDI, MPEG etc.). Below, we list the various formats and the applications that can be used to play them.

2.1 MIDI

MIDI stands for Musical Instrument Device Interface. MIDI files usually have the extension .mid. They contain sequencing information, that is, information on when to play what instrument in what way, etc. Depending on your hardware (and maybe the software you use to play them), the sound might be awesome, or it might be downright crappy.

In the later 1.3.x kernels (the ones that started using the Voxware 3.5 driver), at least with the Sound Blaster 16 on my machine, MIDI output (using FM synthesis) will sound funny when you try to play it for the very first time after a boot. This happens when you use mp in the adagio package or when playing Doom (with the musserver patch). The very next time you play MIDI, the output will be fine, though.

The adagio package

This package includes mp (a command-line MIDI file player) and xmp (an XView based MIDI file player). You will need the SlingShot extensions to use xmp. It also contains other programs for playing Adagio scores (I don't know much about this).

If you have a GUS, mp can also play MOD files (see section Modules for more information on modules).

One little annoying bug (as of version 0.5) is that the sound breaks at the end. Namely, instead of ending the sound the way the MIDI file specifies, it ends by playing the note right before the last one in a long interval. It hasn't stopped me from using mp, but it might prevent someone from using it for `real' work. It also starts up relatively slowly.

The package does not mention any copyright (at least none that I can find), so I assume it can be freely redistributed and modified. Don't hold me to my word, though.

It is a port of the CMU MIDI Toolkit to Linux (well, there was enough added to make this questionable) by Greg Lee ( lee@uhunix.uhcc.hawaii.edu).

It can be found at ftp://tsx-11.mit.edu/pub/linux/packages/adagio05.tgz. The binaries included here are in a.out format (linked with ancient libraries), and the xmp binary segfaults in a X11R6 environment (XFree86 3.1.1, libc 4.7.2). The mp binary works fine.

You will need a bit of hackery to compile it. Actually, it's not much of a hackery. All you have to do is to include the -lfl switch at the end of SHROBJ and XMPOBJ in the Makefile. This is to link in the flex library, which is not linked in by default. Then follow the installation instructions. And don't forget to have XView and the SlingShot extensions installed if you want to compile xmp.

timidity

Some people recommend this experimental program because of good sound quality (which is very true, it's much better than mp on a Sound Blaster 16, though probably won't be much different on a GUS). However, it suffers from high CPU loads. It plays MIDI by first converting MIDI to WAV and then plays the WAV (you can also convert a MIDI file to a WAV file without playing if you want). This is the reason for its CPU intensive nature.

It also has an optional ncurses, SLang, or Motif interface. As far as I know, a statically linked timidity binay with the Motif interface is not available.

You need Gravis Ultrasound patch files to use this. A small collection of GUS patch files can be found at ftp://sunsite.unc.edu/pub/Linux/apps/sound/timidity-lib-0.1.tar.gz. You'll want to find much more if you want to properly use timidity. Look into the FAQ included with timidity for more information. timidity itself can be found at ftp://sunsite.unc.edu//pub/Linux/apps/sound/timidity-0.2h.tgz.

It is written by Tuukka Toivonen ( titoivon@snakemail.hut.fi).

playmidi

This is a MIDI player that plays to FM, GUS, and external MIDI. It does not have proper OPL3 support (trying to use OPL3 output will probably give you a very quiet time), so that the quality of the MIDI output is lower than that of mp in the adagio package (for people like me who don't have a GUS or external MIDI). It doesn't have mp's annoying little bug, though.

This program also has an option for real time playback with ANSI graphics tracking all the notes on each channel and the current playback clock.

Source code for this may be freely distributed in unmodified form.

It was written by Nathan Laredo, who said that he would be unreachable for four to eight years after January 1995. Alex Mohr ( dzur@u.washington.edu) made some bug fixes.

It can be found at ftp://sunsite.unc.edu/pub/Linux/apps/sound/players/playmidi-1.2.tgz.

2.2 Modules

Modules (in computer music) are digital music files, made up of a set of samples and sequencing information, telling the player when to play which sample (instrument) on which track at what pitch, optionally performing an effect like vibrato, for example.

An advantage it has over MIDI is that it can include almost any kind of sound (including human voices). Another is that it sounds just about the same on any platform, because the samples are in the module. A disadvantage it has is that it has a much larger file size compared to MIDI. Another one is that it has no real standard format (the only `real' one is the ProTracker, which many modules aren't quite compatible with). It originated on the Amiga.

They usually have the extension .mod. There are many other extensions depending on what format they are in.

tracker

This very portable program (it has been ported to many platforms) plays Soundtracker and Protracker music modules. It uses 16 bit stereo output, and I consider the quality to be very good. It suffers from high CPU loads, though. The CPU load can be reduced by using the -mono option.

This is a giftware program (quoting the author). It is by Marc Espie ( Marc.Espie@ens.fr).

A version of this with the Makefile already tweaked for Linux is at ftp://sunsite.unc.edu/pub/Linux/apps/sound/players/tracker-4.3-linux.tar.gz.

s3mod

This plays 4/6/8 track MOD modules and Scream Tracker 3 modules. It uses 8 bit mono output, so I recommend using tracker instead of s3mod for playing ordinary MOD files (unless you have an 8 bit mono soundcard, or an underpowered machine). It has a much smaller CPU load compared to tracker.

This is copyrighted by Daniel Marks and David Jeske ( jeske@uiuc.edu), but you can do anything you want with it (except that you can't claim you wrote it).

It can be found at ftp://sunsite.unc.edu/pub/linux/apps/sound/players/s3mod-v1.08A.tar.gz.

gmod

This is a music module player for the Gravis Ultrasound card. 4/6/8 channel MOD, 669, MultiTracker, UltraTracker, and S3M are the supported formats.

It requires version 3.0 or later Voxware sound driver. And a GUS, of course.

This can be freely distributed. It was originally written by Hannu Savolainen, and now maintained by Andrew J. Robinson ( robinson@cnj.digex.net).

It can be found at ftp://sunsite.unc.edu/pub/Linux/apps/sound/players/gmod+x-2.0.tgz.

mod

This alpha program plays MODs (15/31-instrument, up to 32 voices), MTMs, ULTs and S3Ms on the Gravis Ultrasound card. It has an ncurses interface. It can also use packed modules if you have gzip, lharc, unzip, and unarj installed.

This requires at least version 3.0 of the Voxware sound driver. You also need ncurses.

It is written by Mikael Nordqvist ( mech@df.lth.se or d91mn@efd.lth.se).

It can be found at ftp://sunsite.unc.edu/pub/Linux/apps/sound/players/mod-0.6.tgz.

2.3 MPEG audio streams

MPEG is a standard specifying the coding of video and the associated audio for digital storage. MPEG is usually associated with video, but the audio part of the standard can be used separately. The audio part of the MPEG standard defines three layers, layer I, II, and III. Layer II MPEG audio files usually have the extension .mp2. The files are usually rather large (three to six megabytes), but the quality is very good. A two megabyte layer II MPEG audio file will probably take up 25 megabytes for a raw PCM sample file with the same quality.

maplay

This is the only player available that I know of that plays MPEG audio streams. However, it has only support for layer I and layer II. It lacks support for layer III as of version 1.2. It supports 16 bit sound cards on Linux (though some 16 bit sound cards are reported not to work).

It is very CPU intensive, taking up to about 55% CPU time on a 60MHz Pentium (there will be very noticeably pauses if you try ls /dev). The output is intolerable on a 66MHz 486 because the CPU just can't catch up with the sound. If this happens to you, try playing only one side of the audio stream (with the -l or -r option), instead of the default stereo.

A slight change in one of the files may be necessary in order to compile it. Mainly, you may need to add the following line to the beginning of the file configuration.sh.

#! /bin/sh

The author is Tobias Bading ( bading@cs.tu-berlin.de).

maplay can be found at ftp://sunsite.unc.edu/pub/Linux/apps/sound/players/maplay1\_2.tar.gz.

2.4 WAV

Quote from the sox man page:

These appear to be very similar to IFF files, but not the same. They are the native sound file format of Windows 3.1. Obviously, Windows 3.1 is of such incredible importance to the computer industry that it just had to have its own sound file format.

These usually have the extension .wav.

Also see section sox for another WAV player besides the ones listed here.

wavplay

This unfinished program has a command line interface and an X Window interface for playing and recording in WAV format.

Copyright is not explicitly mentioned. It is by Andre Fuechsel ( af1@irz.inf.tu-dresden.de).

It can be found at ftp://sunsite.unc.edu/pub/Linux/apps/sound/players/wavplay021.tar.z.

2.5 Other stuff

sox

This program is actually a converter, that is, it converts one sound format to another. When invoked as play, however, plays the sound (the play application in the Sound HOWTO probably refers to this). It supports raw (no header) binary and textual data, IRCAM Sound Files, Sound Blaster .voc, SPARC .au (w/header), Mac HCOM, PC/DOS .sou, Sndtool, and Sounder, NeXT .snd, Windows 3.1 RIFF/WAV, Turtle Beach .smp, CD-R, and Apple/SGI AIFF and 8SVX formats (a lot of these formats I have no experience with, I just took it from the man page).

It is written and copyrighted by many people, and can be used for any purpose.

It can be found at ftp://sunsite.unc.edu/pub/Linux/sound/Lsox-linux.tgz.

cat

One might think what cat, the sometimes overused concatenating utility, has to do with playing sounds. I'll show a use of it through an example.

$ cat sample.voc > /dev/dsp
$ cat sample.wav > /dev/dsp
$ cat sample.au > /dev/audio

Doing a cat of an .au file to /dev/audio will always work, and if you're lucky enough that the file has the right sample rate etc., a cat of a sound file that uses PCM samples (like .wav or .voc) to /dev/dsp might even sound right.

This isn't a totally useless use of cat. It might be useful, for example, if you have a sound file that none of your programs recognize, and you know that it uses PCM samples, then you might be able to get a very approximate idea on how it sounds like this way.


Previous Next Contents