Sound Sample Format (SOUNDS.DAT)

From WTFwiki
Jump to navigation Jump to search

SOUNDS.DAT:

This file contains all the sound effects used by OMF. It is split into a number of blocks, the first of which is a header block describing where in the file each block begins and ends.

Block 0, the header block, is a sequence s of dwords. Block i is stored in the file from offset s[i] to offset s[i+1]-1. The blocks start at the beginning of the file, so the offset of the header block is 0, the first four bytes of the file are 0x00, and next four bytes of the file contain the length of the header block. There is one final block which runs from s[n] to the end of the file.

Blocks 1 onwards are sound effects in raw format, with unsigned 8-bit mono samples. A good typical frequency for playback is 8kHz. OMF has the ability to play these sounds back at other rates, in order to apply a frequency shift to the sound.

The block numbers correspond to the sound effect numbers in the Sound Effects Test (press Alt-S-F then look in the Configuration menu). SOUNDS.DAT defines 299 sounds, of which most are entirely silent and only one sample long ("\0\0").

Precisely 65 sounds are non-silent:

1-6, 10-17, 19-21, 23-58, 61-72

Note that the sounds are numbered from 1, not 0. BK and AF files reference sounds in SOUNDS.DAT this way. The 30 byte footer for both AF and BK files defines a mapping from AF/BK sound IDs to SOUNDS.DAT sound IDs. See the AF file reference for more information.


A useful command to convert the raw files into WAV files is as follows:

 sox -r 8000 -u -b -c 1 sound.raw sound.wav

Sample implementations

Python parser

def read_sounds(f):
    import struct
    _, size = struct.unpack('<LL', f.read(8))
    blocks = (size,) + struct.unpack('<%dL' % (size/4-2), f.read(size-8)) + (0,)
    return [f.read(j-i) for i, j in zip(blocks, blocks[1:])]

External Links