This application note describes a simple and easy-to-use solution to help design and
develop products with an audio output, for example, toys, white goods, washing machines,
and alarms.
Audio data generally require the storage of a lot of memory. However, the memory space
needed to preserve such data can be reduced by compressing the audio data via a
specified compression method. Processing these data is a complex task requiring powerful
microcontrollers such as DSP or audio chip. Usually, 8-bit microcontrolles do not offer either
a large memory or a high computing performance.
The software solution offered in this application note reconstructs audio signals from
compressed samples. A simple audio codec based on an adaptive differential pulse coded
modulation (ADPCM) algorithm is used and advantage is taken of the advanced STM8S
core with its 3-staged pipeline and 16 or 24 MIPS peak performance.
The digital samples are usually converted to an analog signal by some external or onchip
digital-to-analog converter (DAC). There are a lot of applications where the high fidelity
audio output is not a priority and/or the use of an external DAC is not a suitable costeffective solution for 8-bit microcontrollers. To reduce costs and to offer a good quality audio,
an ideal solution is to generate an audio signal using pulse width modulation (PWM).
The example firmware and application hardware design are provided with this application
note to enable easy porting of the offered solution to the final application.
ADPCM is a fixed length codeword audio codec which reduces redundant information from
audio waveforms. The information core is separated from the correlated waveform samples
by encoding differences between the current samples and the predicted ones. As the
correlation between consecutive audio samples is generally high, this method is reasonably
effective and preserves good audio quality. The ADPCM codec, which is based on coding
waveforms in time domains, is much less complex than codecs based on voice perception
(vocoders) that operate in frequency domains. For these reasons, the ADPCM codec is the
best choice for the audio output on 8-bit microcontrollers.
The ADPCM algorithm has been developed for speech coding. It is implemented in several
steps and is used in telephone systems like ITU-T G.726 (covering CCITT G.721 and G.723
standards). G.726 and similar telecommunication codecs, offer several advanced features
which are necessary for successful transmission and streaming. Such features include
synchronous coding adjustment, tone detection to carry data modem signals, adaptated
speed control, and recovery from transmission error conditions. These features lead to
additional algorithm complexity which either requires the use of a digital signal processor
(DSP) or lowering the encoding/decoding sample rate. Fortunately, such features do not
bring many additional benefits to the microcontroller for coding/decoding the audio or
speech signals. Less complex alternatives can be found.
1.2 Interactive multimedia association (IMA) ADPCM
The IMA
different computers platforms, for example in Microsoft® Sound Recorder or Apple®
QuickTime®. It was originally offered by Intel/DVI® as an open standard for use by the IMA.
The reference algorithms and recommended formats were initially developed by the digital
audio technical working group (DATWG) and refined by the digital audio focus group (DAFG)
of the IMA. These groups are no longer active.
The IMA DATWG reference algorithm is less complex than the G.726 algorithm. The number
of encoding/decoding CPU cycles needed is reduced by using fixed prediction and by
replacing complex floating point mathematical operations by look-up tables. The
implementation of the ADPCM codec presented in this application note is compatible with
the IMA reference algorithm published by the IMA DATWG/DAFG in the “Recommended
Practices for Enhancing Digital Audio Compatibility in Multimedia Systems”, revision 3.00
(see References).
(a)
ADPCM codec is one such alternative solution. This codec is widely used across
a. IMA is a computer/audio/video industry trade association that has worked to promote multimedia application
development.
Doc ID 17011 Rev 13/13
ADPCM codecAN3143
3
Q
3
D
3
,
3
P
Q
)NVERSEQUANTIZER
0REDICTOR3TEPSIZEADAPTOR
AI
1.3 IMA ADPCM decompression
The IMA ADPCM decompression algorithm compresses samples which are stored as 4-bit
signed two’s complement values. The result is decompressed samples in linear 16-bit two’s
complement format.
The input sample (S
obtain a difference (S
S
. The resulting decompressed linear sample is the sum of Sd and the predicted sample
d
(S
). As Sp is a simple zero order hold function, Sd is simply added to the previous output
p
value. The step size is adapted according to S
) is dequantized using an inverse quantizer with an adapted step (q) to
q
). To reduce quantization errors, one half of the step size is added to
d
. The decoder preconditions are that Sp is
q
cleared and that the quantization step is set to smallest one.
Figure 1.ADPCM decoder
4/13Doc ID 17011 Rev 1
Loading...
+ 9 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.