AN2931
1
ADPCM algorithm
1.1
General overview
Adaptive differential pulse-code modulation, or simply ADPCM, is an audio algorithm for
waveform coding, which consists in predicting the current signal value from previous values,
and transmitting only the difference between the real and the predicted value.
In plain pulse-code modulation (PCM), the real or actual signal value is transmitted.
The advantage of ADPCM is that the difference between the predicted signal value and the
actual signal value is usually quite small, which means it can be represented using fewer
bits than the corresponding PCM value.
Depending on the desired quality and compression ratio, the differential signal is quantized
using 4 (2 bit), 8 (3 bit), 16 (4 bit) or 32 (5 bit) levels.
Many implementations of the ADPCM algorithm exist. They differ by the quantization and
the prediction patterns.
In this application note, we provide a 4-bit quantization algorithm, developed by the
Interactive Multimedia Association (IMA), IMA ADPCM.
IMA ADPCM was chosen for several reasons:
●
it can operate at different sampling rates between 8 kHz and 44.10 kHz
●
it guarantees good quality with low CPU usage and memory size requirements
●
it has widespread implementations, for instance in the Windows and MAC operating
systems
The IMA ADPCM algorithm is fully described in a document published by the IMA Digital
Audio Focus and Technical Working Groups: "Recommended Practices for Enhancing
Digital Audio Compatibility in Multimedia Systems" revision 3.
1.2
ADPCM algorithm implementation
The IMA ADPCM algorithm provided in this application note is used to encode audio files
that have the following specification:
●
Audio format: PCM
●
Audio sample size: 16 bits
●
Channels: 1 (mono)
●
Audio sample rate: from 8 kHz to 44.1 kHz
Each 16-bit PCM sample is encoded into a 4-bit ADPCM sample, which gives a
compression rate equal to ¼.
The implementation of the IMA ADPCM algorithm consists in two functions, one that codes
and the other that decodes the audio samples.
The ADPCM firmware is composed of two files:
a)
b)
adpcm.c: it contains the source code of the two ADPCM functions that perform the
coding and decoding.
adpcm.h: it is the header file of adpmc.c. It should be included in the files where
the ADPCM functions are called.
Doc ID 15349 Rev 2
ADPCM algorithm
5/15
Need help?
Do you have a question about the STM32F103 Series and is the answer not in the manual?
Questions and answers