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; the same codec as WAV format tag 0x0200; described below. SoX’s comment and VOC.TXT write 0x2000 or 0x02000, but Creative’s guide, SoX’s code and FFmpeg use 0x0200 |
Creative’s Sound Blaster Series Hardware Programming Guide (appendix B) lists exactly these values: 0 to 3 for the pack method of blocks 1 and 8, and the whole table for block 9 (it gives 0x0200 as “Creative 16-bit to 4-bit ADPCM”).
Multi DAC. VOC.TXT adds a compression type of 3 plus the number of
channels, “multi DAC” (and says the developer’s manual does not have it). The “Sound Blaster: The Official
Book”, quoted on the MultimediaWiki’s talk page, lists the pack types 4 to 10 as “1 channel multi” to “7 channel
multi” (the book’s second edition, read in full, lists only 0 to 3 for the pack type). Creative’s own guide lists only 0 to 3. No source says how the samples of a multi-DAC block are laid
out (the book “doesn’t explain how the various packed formats work”), so the explorer names these values
(5, and 8 to 10; in blocks 1 and 8 it also notes that 4, 6 and 7 are multi-DAC values there) and labels the
sound “not yet decoded”. In block 9 the values 4, 6 and 7 are the 16-bit, A-law and µ-law codecs, and
FFmpeg and SoX read them like that in blocks 1 and 8 too.
Multi DAC in Creative’s own driver. The Sound Blaster Pro’s CT-VOICE.DRV (5,124 bytes,
from DRIVER.LZH on “Sound Blaster Pro Disk #2”, dated 29 November 1991), read as code and not run, has a
table of eleven DSP command bytes indexed by the pack value of blocks 1 and 8 (file offset 0x0E4F): 0 gives
0x14 (8-bit DMA), 1 gives 0x75, 2 gives 0x77, 3 gives 0x17 (the ADPCM
commands with a reference byte), and 4 to 10 give 0x61 to 0x67, which is 0x60 plus the number
of channels (“3 plus channels”). For a block that continues a sound the driver then clears the low bit of the ADPCM
commands (0x74, 0x76, 0x16, no reference byte) and sets bit 3 of the
multi-DAC ones (0x69 to 0x6F). The driver’s block dispatch table (offset 0x00C1) handles
only types 0 to 8; type 9 and above are skipped. The driver does not change the data bytes: its whole play and record path (offsets 0x06F4 to 0x0D48) was read, and it
programs the DMA controller (mode 0x44 to record, 0x48 to play), issues only DSP commands 0x14, 0x24, 0x48, 0x40, 0xA0 and 0x91,
and its interrupt handlers only acknowledge and chain on; the one data byte it reads is the ADPCM reference byte at block
offset 7, which it plays once as a one-sample 8-bit block. It hands the block to the DMA
controller as it is, so the multi-DAC byte arrangement is whatever the DSP command consumes, and nothing in the
file or the driver says what that is. The ADPCM expansion is also done by the DSP and not by the driver, so the driver holds no
step tables. Source: one driver (I) for the command table; the pack-to-channels rule is also in VOC.TXT (V).
The Sound Blaster 16 driver. The Sound Blaster 16 CT-VOICE.DRV (31,866 bytes, “Creative
Loadable Voice Memory Driver 4.01”, 1991 to 1993) is stream 2 of DRIVER.PVL on the “Applications” floppy of the
Sound Blaster 16 set (a .PVL is a chain of PKWARE DCL streams followed by [PVM] member headers).
Read as code and not run, it dispatches on the block type 0 to 9 (jump tables at 0x1E6C and 0x202C). Its block 1 handler
(offset 0x228A) keeps the bits per sample of the pack values in the table 8, 4, 3, 2 and rejects every pack value above 3
(error 7), so the multi-DAC values 4 to 10 are not played by this driver either. Its block 8 handler sets the channel
count to the mode byte plus one and does not look at the pack value, so a stereo block with a pack value of 1 to 3 is
passed on with 2 channels and 4, 3 or 2 bits; the driver contains no ADPCM step tables and does not change the data. Its block 9 handler
reads the rate (block offset 4), bits (8), channels (9) and codec word (10), and the codec word goes through one routine (offset
0x3B00) that stores it as a wave-format tag: 0 and 4 give 1 (PCM), 1 to 3 give 1 with the ADPCM flag, 6 gives 6, 7 gives 7,
0x0200 gives 0x0200, and 5 and everything else are refused. So codec 0x0200 is only handed on as a format tag to the
layer below; the expansion itself is not in this driver. Source: one driver (I). Still not known: how the multi-DAC
samples are arranged, and how the layer below expands stereo ADPCM or codec 0x0200.
The layers below the driver. The same DRIVER.PVL holds nine members, each checked by its stored CRC-32:
AUXDRV.DRV, CT-VOICE.DRV, CTMIDI.DRV, CTVDSK.DRV, CTWDSK.DRV,
CTWMEM.DRV, ORGAN.DRV, CTMMSYS.SYS (the integration driver) and CTSB16.SYS (the
Sound Blaster 16 physical-level driver, “CTSOUND”). Read as code and not run, neither of the last two contains the DSP ADPCM command
bytes (0x16, 0x17, 0x74 to 0x77) or step tables, and the codec words are not expanded there (I). The Sound Blaster 16’s own work
for codec 0x0200 is in the signal-processor files of CSP.PVL: WFM0200A.CSP, WI0200.CSP and
WO0200.CSP are RIFF “CSP ” microcode files (the first is labelled “Creative ADPCM compression”, 1994), with the same
for the wave format tags 0x0001, 0x0006, 0x0007, 0x0011, 0x0202 and 0x0203 (the file names are read as hexadecimal tags; I). Their instruction set is not documented anywhere that was found, so the
expansion they perform is not read (U). Creative’s own software codec for 0x0200 was read instead: see
the end of the 0x0200 section.
The Creative ADPCM codecs are described in their own section. The raw sample layouts (8-bit unsigned, 16-bit signed, A-law, µ-law) are the same as in headerless audio: see Raw audio sources, which lists VOC sound-data blocks as a source, and ADPCM.
Creative ADPCM (codecs 1, 2 and 3)
The three codecs turn the 8-bit samples of a Sound Blaster into 4, 2.6 or 2 bits each. Creative’s guide says the DSP’s ADPCM output is mono and that the first byte of the compressed data is always a reference byte, “not ADPCM code but an actual data byte value”, for the first block of a transfer; later blocks use other DSP commands that take no reference byte. In a VOC file the first byte of the data of a type 1 (or type 9) block is the reference byte: an unsigned 8-bit sample, which is also the first sample played. The codes follow, and a type 2 block continues them with the state the block before left (no new reference byte).
| Codec | Codes in a byte | Code | Step rows | Row units | Row goes up when |
|---|---|---|---|---|---|
| 1: 4 bits | 2: high nibble, then low | sign bit 3, magnitude m = bits 0 to 2 | 4 | 1, 2, 4, 8 | m ≥ 5 |
| 2: 2.6 bits | 3: bits 7 to 5, bits 4 to 2, then bits 1 to 0, which are a 2-bit code | 3-bit codes: sign bit 2, m = bits 0 and 1; the 2-bit code: sign bit 1, m = bit 0 | 5 | 1, 2, 4, 8, 16 | m = 3 (never on the 2-bit code) |
| 3: 2 bits | 4: bits 7 to 6 first | sign bit 1, m = bit 0 | 6 | 1, 2, 4, 8, 16, 32 | m = 1 |
For each code the decoder takes a step of ((2m + 1) × unit) >> 1 (a whole number of
8-bit steps) and adds it to the last sample, or subtracts it when the sign bit is set,
keeping the sample from 0 to 255. Then the row, which starts at 0 after a reference
byte, goes down by one when m is 0 (not below row 0) and up by one when the last
column says so (not above the last row). The explorer plays these as 16-bit samples
of (sample − 128) × 256.
Worked example, 4 bits: reference 140, then the byte 0x9A. Code 9 has sign 1
and m = 1, row 0: the step is (3 × 1) >> 1 = 1, so 140 − 1 = 139, and m is not 0 or
5 or more, so the row stays 0. Code 10 (0xA): m = 2, step (5 × 1) >> 1 = 2, 139 − 2 = 137.
Limits of the hardware. Creative’s guide lists the DSP’s ADPCM rates: 4 to 12 kHz for 4-bit, 4 to 13 kHz for 2.6-bit and 4 to 11 kHz for 2-bit (the Sound Blaster Official Book gives the same maxima). The book also says that silence blocks are cut out first and each data block is then compressed on its own, that the DOS editor VEDIT2 compresses only after capture and cannot edit a packed file, and that packing cannot be done at the highest sample rates.
Where the rules come from. Creative’s guide gives no algorithm for the DSP’s ADPCM. The 4-bit
and 2-bit rules are those of SoX’s adpcms.c (16-bit scale: units × 256) and the DOSBox and
DOSBox-X Sound Blaster models (tables and 8-bit arithmetic). For the 2.6-bit codec the two differ from what
real data shows. FFmpeg’s samples include one recording coded three ways, BBC_4BIT.VOC,
BBC_3BIT.VOC and BBC_2BIT.VOC (104,461 samples each, 11,111 Hz). Decoded by the SoX
and DOSBox rule, the 4-bit and 2-bit files agree closely (rms difference 9.5 of 255 steps) but the 2.6-bit
file drifts away (rms 59). A search over the layout and rules of the 2.6-bit codec found one that follows the
4-bit file to within 5.9: the table above, whose last row has unit 16 (SoX and DOSBox have 10) and whose third
code is the 2-bit code of the low two bits (SoX and DOSBox shift it left by one into a 3-bit code). That
version is the one the explorer uses. DOSBox has 6 where the 2-bit rule gives 16 for the first value of the
2-bit codec’s last row, which looks like a slip. FFmpeg’s adpcm_sbpro decoders use another rule
(no half step, other limits): on these three files their output does not agree between the codecs at all
(rms 8,000 to 10,700 in 16-bit units, against 1,500 to 2,400 for the explorer’s).
The stereo case is not documented: Creative’s guide lists ADPCM for mono only. For several channels the explorer takes one reference byte a channel and lets the codes take turns between the channels, as FFmpeg does for its decoders.
Creative ADPCM, 4 bits to 16 bits (codec 0x0200)
Block 9 only. It is Creative’s WAVE_FORMAT_CREATIVE_ADPCM (the guide describes the WAV header: 4 bits a sample,
block alignment 1 for mono and stereo, a revision word of 0), a variation of Yamaha ADPCM. There is no reference byte.
Each channel starts with predictor 0 and step 511. A byte holds two nibbles, the high one first; with two
channels the nibbles take turns, left then right, each channel with its own predictor and step. For a nibble, the sign is bit 3
and m is bits 0 to 2. Two sources give the rule, and they differ; the explorer decodes by Creative’s own code
unless the viewer option “Codec 0x0200” at the top of the window is set to FFmpeg. What they share:
step = (table[m] × step) >> 8, held within 511 to 32767
table = 230, 230, 230, 230, 307, 409, 512, 614 (0xE6, 0xE6, 0xE6, 0xE6, 0x133, 0x199, 0x200, 0x266)
the predictor, held within −32768 to 32767, is the 16-bit sample
Rule 1, FFmpeg and the MultimediaWiki (“Creative ADPCM”; FFmpeg’s adpcm_ct):
diff = ((2 × m + 1) × step) >> 3
predictor = ((predictor × 254) >> 8) ± diff (minus when the sign is set)
The state continues through all the blocks of the sound; the explorer does not reset it at a new block 9 (FFmpeg does not either). With the option on FFmpeg, checked sample for sample against FFmpeg’s decode of built files, mono and stereo.
Rule 2, Creative’s own code (the default). The Sound Blaster 16 Windows applications disk holds
CTWAVE.PVL, whose WFLT0200.DLL (“Creative ADPCM Wave Filter”, exports FLTIMPORTWAV and
FLTEXPORTWAV) is a Windows DLL with the encoder and the decoder; the same routines occur twice in
WFM0200.ACV of WINDRV.PVL. Read as 16-bit code and not run (V for what the code does), it has the step table at
file offset 0x28C4 (the table above), a step that starts at 511 and is held within 511 to 32767, high nibble first, and for stereo
the nibbles take turns between two separate states. It differs from rule 1 in two places: the code has no decay of the old
predictor (the predictor is only added to), and the difference is built from the shifted steps one bit at a time,
diff = (m & 4 ? step : 0) + (m & 2 ? step >> 1 : 0) + (m & 1 ? step >> 2 : 0) + (step >> 3) (each shift of the already shifted value; the sum held to 32767)
predictor = predictor ± diff (minus when the sign is set)
so nibble 7 at step 511 adds 956, where rule 1 gives 958. Creative’s encoder reconstructs the predictor the same way, which is
how the missing decay is known. No real file of codec 0x0200 was found to settle which of the two is right on real data (I).
Creative’s own code is the default because it is the vendor’s implementation, read as code (V); rule 1 is a published description
and a widely used decoder, and stays as the option. The two are tested apart in test-voc-built.mjs (built files, mono and stereo).
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 was a slip. The formula above is the one Creative’s guide gives
(“time constant = 65536 − (256 000 000 ÷ (channels × sampling rate))”, with channels 1 or 2, and
for a type 1 block only the high byte stored: 10,000 Hz mono is 0x9C00, stored as 0x9C),
and the one the MultimediaWiki, the Game Modding wiki and Kaitai give. The guide’s worked value
for 44,100 Hz, 59732 (which the guide also prints as 0E95H; 59732 is 0xE954), is one more than the formula gives:
65536 − 256,000,000 ÷ 44,100 = 59,731.01. The guide’s second example, 22,050 Hz stereo, gives the same number. Read back with the formula,
59732 is 44,108 Hz and 59731 is 44,100 Hz.
Source: Creative Labs, Sound Blaster Series Hardware Programming Guide, Appendix B “Creative Voice File (VOC) Format” (guide pages B-2 to B-12), and its chapter 3 for the ADPCM rates and the reference byte. The block and codec tables on this page and the blocks page were compared with that text by script; the Creative ADPCM algorithms are not in the guide (see “Where the rules come from”).
Samples
Uncompressed samples are stored one after another, with stereo samples as interleaved frames (left, right, left, right, …). Eight-bit samples are unsigned, and 16-bit ones signed and little-endian.