Descent 1,2 audio

From MultimediaWiki
Jump to: navigation, search

Credit

The information on this page was originally based on one of the many format documents written up by Valery V. Anisimovsky, available on http://wotsit.org/ and many other sites across the internet.

Byte Order

All multi-byte numbers are storedin little endian format.

Descent 1 Sound FX

In Descent 1 all sound files are stored in DESCENT.PIG file except for one file: DIGITEST.RAW which is in DESCENT.HOG.

The Descent 1 (v1.0) .PIG file has the following header:

 bytes 0-3   nFiles
 bytes 4-7   nSoundFiles

nFiles -- this is the number of non-sound files in the PIG,

nSoundFiles -- this is the number of RAW sounds in the PIG.

Following the header are (nFiles) records describing non-sound files. What we need to know about these records is that each of them is 17 bytes long.

After those records are (nSoundFiles) records describing sounds. Each record has the following format:

 bytes 0-7    szFileName
 bytes 8-11   nSamples
 bytes 12-15  dwFileSize
 bytes 16-19  dwFileStart

szFileName -- this is the name of the sound file, padded with zeroes. Note that there can be 8-character names which are thus not zero-terminated.

nSamples -- the number of samples in RAW file.

dwFileSize -- the size of RAW file (in bytes).

dwFileStart -- the starting position of the RAW file relative to the beginning of the data files in PIG. That is, to get the starting position of the RAW file relative to the beginning of the PIG file you need to add (dwFileStart) to (sizeof(PIGHeader)+nFiles*17+nSoundFiles*sizeof(DSNDEntry)).

Starting at that position, there is audio formatted as uncompressed 8-bit unsigned mono PCM data. All sound files in Descent 1 .PIG should be played at 11025 Hz.

1.4 Format

Note that Descent v1.4 has slightly different .PIG file. Namely, it starts with a 32-bit value which is the position (relative to the .PIG file beginning) of PIGHeader. Starting at that position is a PIGHeader which is the same as described above.

Descent 2 Sound FX

In Descent 2 all sound files are stored in DESCENT2.S11 and DESCENT2.S22 except for DIGITEST.RAW which is in DESCENT2.HOG.

.S11 and .S22 files have the following header:

 bytes 0-3    szID
 bytes 4-7    dwDummy
 bytes 8-11   nFiles

szID -- string ID is always "DSND",

dwDummy -- unknown

nFiles -- the number of files in .S11/.S22 file.

Following the header are (nFiles) records (just the same as for Descent 1). Just like in Descent 1, (dwFileStart) field of each entry is the starting position of the RAW file relative to the beginning of RAW files. That is, to get the starting position of the RAW file relative to the beginning of the .S11/.S22 file you need to add (dwFileStart) to (sizeof(DSNDHeader)+nFiles*sizeof(DSNDEntry)).

Playing the Audio

Each file in .S11/.S22 is 8-bit unsigned mono PCM data. PCM data from .S11 should be played at 11025 Hz, while PCM data from .S22 should be played at 22050 Hz.