Byte Block Audio
Byte Block Audio is a simple audio
compression scheme for use with embedded devices. Multiple
channels are supported, as are multiple bit-depth and
sample-rates. There is a reference encoder for Windows,
with source code included.
You can grab the latest version of BBA here.
(July 15, 2008: see the change log at the bottom of this page.)
- Multiple levels of compression: 1, 2, 3, 6, or 7 samples per byte
- Comes with an encoder/decoder
- Windows exe included
- C++ source included (ugly!)
- drop one or many WAV or OGG files to generate BBA files
- drop one or many BBA files to generate WAV files (check the quality)
- No external dependencies
- Public Domain
Byte Block Audio is a very simple & scalable type of ADPCM.
BBA compresses a fixed number of samples into a single byte,
hence the name [8^). Each sample is coded as a delta from
the previous sample.
Each byte in the compressed bitstream has 2 parts, the "Adaptive"
portion, and the "Delta Pulse Code Modulation" portion. Each
delta is encoded using a fixed number of bits, then scaled with
a "shift left" operation (SHL, to avoid multiplication). The
SHL variable is called the "scaler" in the reference code. The
"Adaptive" portion of the compressed byte will change the scaler,
then the remaining bits of the compressed byte will be decoded to
represent the delta from the previous sample. The initial sample
value is set to 0, and the initial scaler value is set to 1.
The desired number of samples will control the distribution of bits
int the compressed byte. See the following table:
So, for example using 3 samples per byte, the 2 most significant
bits will adjust scaler, then the next two bits will define the
delta for the 1st sample, then the following 2 bits will define
the delta for the second sample, and the last 2 bits define the
delta for the final sample.
|Samples / Byte
There are two schemes for updating the scaler. In the 1-bit scheme
scaler += 1 if the adaprive bit was 1, otherwise scaler -= 1. In the
2 bit scheme, scaler += adapt - 1. This lets the scaler decrease by
1, stay the same, or increase by 1 or 2. This distribution was chosen
because it was deemed better to be able to overshoot the value, than
to slowly ramp up to it.
The decoder is very simple, especially if you only want to decode a
fixed compression level. One thing to notice is the output value is
set to the average of the new value and the last value. This smooths
out the output waveform, and is especially useful for the high
compression levels where each sample only gets a 1-bit delta.
See the C++ source for any questions.