Difference between revisions of "Creative 8 bits ADPCM"
|Line 35:||Line 35:|
Revision as of 11:58, 8 March 2013
- Company: Creative
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.
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.
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.
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.
- 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.