Creative 8 bits ADPCM

From MultimediaWiki
Jump to navigation Jump to search

These ADPCM schemes are used in Creative VOC files. The only reference decoder is a hardware one: the Creative Sound Blaster (Pro). So this documentation is not based on reverse engineering. It's based on wild guessing and empirical tests but gives good enough results.

(Note: The source at https://github.com/joncampbell123/doslib/blob/master/hw/sndsb/sndsb.c claims that this information is incorrect -- this wiki article should be revised to be closer to accurate.)

There are three different variation of this codec, which pack samples to either 4, 2.6 or 2 bits. The 2.6 scheme means that every byte is composed of 3 samples of 3 bits for the first and the second and 2 bits for the last.

The three different schemes use the same algorithm with different initial parameters.

Initialization

The first byte is a raw (not compressed) sample, used as the initial value for prdiction.

step is initialized to 0.

shift is initialized to 2 for 2 bits scheme and to 0 else.

limit is initialized to 5 for 4 bits samples, 3 for 3 bits samples and 1 for 2 bits samples.

Decoding

Every packed sample is composed of a sign bit (the most significant bit), and a value (the other bits). Let's define sign as 1 when the sign bit is 0 and -1 when the sign bit is 1. Now you can decode a packed sample with the following operation

sample = prediction + sign * (value << (step + shift))

sample have to be clamped to fit into an unsigned byte.

Then prediction is updated to the new sample value, and step is updated using this algorithm:

if (value >= limit)
  step++;
else if (value == 0)
  step--;

step must be clamped into the 0..3 range.

External sites

  • The DOSBox source contains code that claims to decode Creative ADPCM as well, but that code has not yet been verified against the information on this page.
  • The VOCEDIT 2 (VEDIT2.EXE) program that came with the Sound Blaster Pro can be used to compress 8-bit PCM .VOC files into all Creative 8-bit ADPCM variants, making it applicable for a reverse-engineering exercise. The same software might be able to unpack packed files as well but this has not been verified. Download link found at VOGONs at http://www.vogons.org/viewtopic.php?t=8634