English
Language : 

VS1053B Datasheet, PDF (54/79 Pages) List of Unclassifed Manufacturers – Ogg Vorbis/MP3/AAC/WMA/MIDI AUDIO CODEC
VLSI
Solution y
VS1053b preliminary
VS1053B
9. OPERATION
9.8.2 Reading IMA ADPCM Data
After IMA ADPCM recording has been activated, registers SCI HDAT0 and SCI HDAT1 have new
functions.
The IMA ADPCM sample buffer is 1024 16-bit words. The fill status of the buffer can be read from
SCI HDAT1. If SCI HDAT1 is greater than 0, you can read as many 16-bit words from SCI HDAT0. If
the data is not read fast enough, the buffer overflows and returns to empty state.
Note: if SCI HDAT1 ≥ 896, it may be better to wait for the buffer to overflow and clear before reading
samples. That way you may avoid buffer aliasing.
Each IMA ADPCM block is 128 words, i.e. 256 bytes. If you wish to interrupt reading data and possibly
continue later, please stop at a 128-word boundary. This way whole blocks are skipped and the encoded
stream stays valid.
9.8.3 Adding a RIFF Header
To make your IMA ADPCM file a RIFF / WAV file, you have to add a header before the actual data.
The following shows a header for mono file. Note that 2- and 4-byte values are little-endian (lowest byte
first) in this format:
File Offset Field Name
Size Bytes
Description
0 ChunkID
4 "RIFF"
4 ChunkSize
4 F0 F1 F2 F3
File size - 8
8 Format
4 "WAVE"
12 SubChunk1ID
4 "fmt "
16 SubChunk1Size
4 0x14 0x0 0x0 0x0 20
20 AudioFormat
2 0x11 0x0
0x11 for IMA ADPCM
22 NumOfChannels 2 C0 C1
1 for mono, 2 for stereo
24 SampleRate
4 R0 R1 R2 R3
0x1f40 for 8 kHz
28 ByteRate
4 B0 B1 B2 B3
0xfd7 for 8 kHz mono
32 BlockAlign
2 0x0 0x1
0x100
34 BitsPerSample
2 0x4 0x0
4-bit ADPCM
36 ByteExtraData
2 0x2 0x0
2
38 ExtraData
2 0xf9 0x1
Samples per block (505)
40 SubChunk2ID
4 "fact"
44 SubChunk2Size
4 0x4 0x0 0x0 0x0 4
48 NumOfSamples
4 S0 S1 S2 S3
52 SubChunk3ID
4 "data"
56 SubChunk3Size
4 D0 D1 D2 D3
Data size (File Size-60)
60 Block1
256
First ADPCM block
316 . . .
More ADPCM data blocks
If we have n audio blocks, the values in the table are as follows:
F = n × C × 256 + 52
R = Fs (see Chapter 9.8.1 to see how to calculate Fs)
B
=
Fs ×C ×256
505
S = n × 505. D = n × C × 256
Version 0.5, 2007-12-03
54