Sound blocks name their codec with a number. Block types 1 and 8 store it in one byte, and type 9 in two; all use the same numbers, though the last code fits only type 9.
Codec values
| Value | Codec | Notes |
|---|---|---|
0x00 | 8-bit unsigned PCM | silence is 0x80 |
0x01 | Creative ADPCM, 4 bits to 8 bits | |
0x02 | Creative ADPCM, 3 bits to 8 bits | also called 2.6 bits |
0x03 | Creative ADPCM, 2 bits to 8 bits | |
0x04 | 16-bit signed PCM | little-endian |
0x06 | A-law | G.711 |
0x07 | µ-law | G.711 |
0x0200 | Creative ADPCM, 4 bits to 16 bits | type 9 blocks only; SoX’s comment says 0x2000, but its code and FFmpeg use 0x0200 |
The text VOC.TXT adds a value of 3 plus the number of channels for
multi-DAC sound, for block type 1. No other public description confirms it.
The Creative ADPCM algorithms are not described in any public VOC document. FFmpeg and SoX decode them, and DOSBox reproduces the card’s behaviour.
Sample rates
Types 1 and 3 give the rate as a one-byte time constant, and type 8 as a two-byte one. Type 9 stores the rate in hertz directly.
| Block | Rate from the time constant tc | tc from the rate |
|---|---|---|
| 1 and 3 | 1000000 ÷ (256 − tc) | 256 − (1000000 ÷ rate) |
| 8 | 256000000 ÷ (channels × (65536 − tc)) | 65536 − (256000000 ÷ (channels × rate)) |
For example, a rate of 11,111 Hz has a type 1 time constant of 166, and 44,100 Hz mono
has a type 8 time constant of 59,731 (0xE953). The formula in
VOC.TXT for stereo divides 25600000 by twice the rate: a factor of 10 less
than for mono, which looks like a slip. The formula above is the one the MultimediaWiki,
the Game Modding wiki and Kaitai give.
Samples
Uncompressed samples are stored one after another, with stereo samples as left, then right. Eight-bit samples are unsigned, and 16-bit ones signed and little-endian.