Skip to content

AUD audio

Formats

Changed in 0.2.0

Westwood's audio format, which holds the game's sound effects, speech and music.

Format
Kind
Binary format
Extension
.AUD
Role
Audio

The game finds every .AUD file by name through the normal file search. A loose file in the game directory replaces a member of a mounted archive with the same name; MIX archives covers which archives are mounted.

Sound effects, music and speech name their files differently:

  • A sound effect’s samples are named in SOUND.INI without an extension. The game tries .WAV, .OGG, .FLAC and .MP3 under each name before .AUD, and plays the first file that decodes. Sound effects covers the size limit and how long a decoded sample stays in memory.
  • A music track’s file is named by its Sound=, or by its THEME.INI ID without that key. The game tries the same extensions in the same order as for a sound effect and plays the first file that decodes. A speech line plays from the .AUD file with its name. The game reads music and speech files while they play and keeps nothing of them in memory afterward. Music covers what happens when a track’s file is missing.

A file with the .AUD extension that holds WAV, OGG, FLAC or MP3 data also plays, as a sound effect, music track or speech line. The game reads such a file by its content when it does not start with a valid AUD header.

A sound effect starts only when all of these hold:

  • the sound effect volume option is above zero, except for the test beep the voice volume control plays outside a game;
  • the volume the sound is played at, after any fade with distance, is above zero;
  • the game was not started with the quiet launch option;
  • its SOUND.INI entry names at least one sample;
  • an audio device is available.

A music track starts only when all of these hold:

  • an audio device is available;
  • the game was not started with the quiet launch option;
  • the music volume is above zero.

An AUD file is a 12-byte header followed by the sample data. Numbers are stored low byte first.

OffsetBytesHolds
02Playback rate in hertz
24Size of the data after the header, in bytes
64Size of the data once uncompressed, in bytes
101Flags: 1 for stereo, 2 for 16-bit samples
111Compression code

The file does not play if any of these holds:

  • the rate is 0;
  • the data size is 0 or less, or larger than the rest of the file;
  • a flag other than stereo and 16-bit is set;
  • the compression code is not one of the three below;
  • the compression code is 1 and the 16-bit flag is set.

Any other rate plays as written, except that a rate above 20000 and below 24000 hertz plays at 22050. Mono and stereo samples both play, at either bit depth.

CodeCompression
0None. 8-bit samples are unsigned and 16-bit samples are signed; stereo samples alternate left and right.
1Westwood delta compression, for 8-bit samples only
99ADPCM, the compression the shipped files use

With code 1 or 99, the data is a series of blocks. Each block starts with an 8-byte header: its compressed size in 2 bytes, its uncompressed size in 2 bytes, and the marker 0x0000DEAF in 4 bytes. A block whose two sizes are equal is stored uncompressed.

Keep each block within these limits:

  • The uncompressed size is at most 8392 bytes and holds a whole number of samples for every channel. The sample ends before a block that breaks this.
  • The compressed size is at most 2098 bytes. Music and speech end before a larger block. A sound effect with code 99 also ends there, unless that block is stored uncompressed.

The sample also ends before a block without the marker, and before a code 1 block that does not decode to its uncompressed size. The blocks before it still play.

Set the header’s uncompressed size to the full decoded size in a code 1 file. A sound effect ends before the first block that would take it past that size. A value of 0 counts as four times the data size.

Source files

Linked at revision 51b52aa38392.

History

  1. Changed0.2.0In development

    Decode delta-compressed AUD files and refuse unknown codecs

  2. Changed0.2.0In development

    Play samples whose format differs from the mixer's

  3. Changed0.2.0In development

    Decode compressed audio frames in isolation

  4. Changed0.2.0In development

    Load sound effects from loose files and any archive