Some “raw” audio files are not a run of samples but a run of codes: each says how the next sample differs from the last. Differential PCM (DPCM) codes the difference; adaptive differential PCM (ADPCM) also changes the size of a step as it goes, so loud passages get coarse steps and quiet ones fine steps. In every one, the decoder carries a state from code to code, so a file cannot be decoded from the middle, only from a place where the state is known: the start, or the start of a block. The explorer’s Format option lists each one under DPCM or ADPCM.
Byte and word deltas
Each code is a signed number, 8 or 16 bits, that is added to the running value, which
starts at 0 and wraps at the width of the code. This is the plain DPCM of a few
capture programs and the delta filter of audio compressors. Example, 8 bits: the
bytes 05 05 FB 00 give 5, 10, 5, 5.
SDX2 square-root delta
Interplay’s SDX2 codes each sample in one byte n (signed). Its value is
2 × n × |n|. When the byte is even this is the sample itself; when the byte is
odd it is added to the previous sample. The result is clipped to 16 bits. The bytes
10 20 30 03 04 05 F0 81 00 decode to 512, 2048, 4608, 4626, 32, 82,
−512, −32768 and 0: FFmpeg’s sdx2_dpcm decoder gives the same nine values.
8SVX Fibonacci-delta and exponential-delta
Two 4-bit codes to a byte; each code indexes a table of deltas added to an 8-bit running value that is clipped to −128…127.
| Code | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Fibonacci | −34 | −21 | −13 | −8 | −5 | −3 | −2 | −1 | 0 | 1 | 2 | 3 | 5 | 8 | 13 | 21 |
| Exponential | −128 | −64 | −32 | −16 | −8 | −4 | −2 | −1 | 0 | 1 | 2 | 4 | 8 | 16 | 32 | 64 |
In an IFF 8SVX file the packed body starts with a pad byte and the first sample’s value,
and the high nibble comes first; the explorer’s raw reading has no such start, begins at 0 and
takes the nibble order from Byte order (big-endian is high first, the 8SVX
order). The IFF file itself is on the
8SVX pages. Example: the byte 9A,
high nibble first, is codes 9 and A, deltas +1 and +2, so the samples are 1 and 3.
IMA (DVI) ADPCM
The Interactive Multimedia Association’s 4-bit ADPCM. The decoder keeps a 16-bit predictor and a step index from 0 to 88 into this table of steps:
7 8 9 10 11 12 13 14 16 17 19 21 23 25 28 31 34 37 41 45 50 55 60 66 73 80 88 97 107 118 130 143 157 173 190 209 230 253 279 307 337 371 408 449 494 544 598 658 724 796 876 963 1060 1166 1282 1411 1552 1707 1878 2066 2272 2499 2749 3024 3327 3660 4026 4428 4871 5358 5894 6484 7132 7845 8630 9493 10442 11487 12635 13899 15289 16818 18500 20350 22385 24623 27086 29794 32767
For each 4-bit code c with step s: the difference starts at
s >> 3; add s if bit 2 of c is set, s >> 1 if bit 1,
s >> 2 if bit 0; subtract it from the predictor if bit 3 is set, else add it;
clamp to 16 bits. The index then moves by −1, −1, −1, −1, 2, 4, 6, 8 for the low three
bits of c (the same whichever sign), and is held to 0…88.
Example, bare nibbles from predictor 0 and index 0: the byte 77 is two codes 7.
Code 7 at step 7: 0 + 7 + 3 + 1 = 11, so the sample is 11 and the index becomes 8.
The second 7 at step 16: 2 + 16 + 8 + 4 = 30, so the sample is 41.
Three arrangements of IMA ADPCM are offered:
| Format option | Layout | Samples in a block |
|---|---|---|
| IMA / DVI in blocks (WAVE 0x11) | per channel a 4-byte header (predictor as a 16-bit little-endian number, step index in one byte, one reserved byte), then groups of 4 bytes a channel, the channels in turn; each group is 8 codes, low nibble first | 1 + 8 × ((block − 4 × channels) ÷ (4 × channels)), a channel |
| IMA, bare nibbles | no headers: predictor 0 and index 0 at the start of the data and then a continuous stream of codes, the channels’ codes alternating; Byte order picks the nibble | 2 per byte |
IMA 4:1 (QuickTime ima4) | 34 bytes a channel and packet: a 16-bit big-endian header holding the top 9 bits of the predictor and the 7-bit step index, then 32 bytes of codes, low nibble first; the channels’ packets alternate | 64 a channel |
The Block size option is the WAVE nBlockAlign: the bytes in one block. A
mono block of 256 bytes holds 1 + 252 × 2 = 505 samples; a stereo block of 512
bytes holds 505 samples a channel. FFmpeg writes 1,024-byte blocks (2,041 samples a
channel for mono at 22,050 Hz); other encoders use 256, 512 or 2,048.
When the block size is wrong the first block decodes and the next starts in the wrong
place: the sound is right for a moment at every block that happens to line up and noise between.
Microsoft ADPCM
Blocks again (WAVE 0x02). Each block starts with a header, for each channel in
turn: one byte per channel for the predictor index, then a 16-bit little-endian
delta for each channel, then the channel’s previous sample s1, then
the sample before it s2 (each as a group of one value for every channel).
The first two samples of the block are s2 then s1. Then come 4-bit codes, the high nibble
first, taking the channels in turn.
A code is a signed nibble n (−8…7). The predictor index chooses a pair of coefficients (c1, c2) from
| Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|---|
| c1 | 256 | 512 | 0 | 192 | 240 | 460 | 392 |
| c2 | 0 | −256 | 0 | 64 | 0 | −208 | −232 |
The new sample is (s1 × c1 + s2 × c2) ÷ 256 + n × delta with the division
truncating toward zero, clamped to 16 bits; then s2 = s1,
s1 = the new sample, and delta = max(16, delta × A[code] ÷ 256) with
A = 230, 230, 230, 230, 307, 409, 512, 614, 768, 614, 512, 409, 307, 230, 230, 230 for
the unsigned code 0…15. A block of B bytes holds 2 + 2 × (B − 7 × channels) ÷ channels samples
a channel; a stereo block of 512 bytes holds 500. FFmpeg’s adpcm_ms decoder is
the reference these steps follow.
Yamaha, OKI and Creative: streams of codes
These have no blocks and no headers: a stream of 4-bit codes with the decoder state starting at its initial value. With two channels the codes alternate left and right.
| Codec | Nibble first | State | Output |
|---|---|---|---|
Yamaha (FFmpeg adpcm_yamaha) | low | 16-bit predictor, step from 127 to 24,576; difference table ±1, 3 … 15 times step ÷ 8; step scaled by 230, 230, 230, 230, 307, 409, 512, 614 ÷ 256 (the same eight for the negative codes) | 16-bit |
Dialogic / OKI VOX (FFmpeg adpcm_ima_oki) | high | 12-bit predictor; the IMA index rules over the first 49 steps of the IMA table, from 16 to 1,552 | 12-bit, shown ×16 |
Creative Technology (FFmpeg adpcm_ct) | high | 16-bit predictor that decays by 254/256 each step; step from 511 to 32,767, scaled by 230, 230, 230, 230, 307, 409, 512, 614 ÷ 256 | 16-bit |
All three are verified against FFmpeg’s decoders on the same bytes, for one and two
channels, by the explorer’s tests. Dialogic .vox files are OKI ADPCM at
6,000 or 8,000 Hz and are what the explorer assumes for that extension.
What is not here
More ADPCM codecs exist, among them G.726 and G.722 (the explorer reads them in AU and WAVE files), Sound Blaster 2, 2.6 and 4-bit ADPCM (inside VOC), the Duck, Xbox, Nintendo and PlayStation families and the MPEG-4 and Apple formats. They are not offered as raw reading. See the overview’s Not described list.