|
VS1103B Datasheet, PDF (39/61 Pages) List of Unclassifed Manufacturers – MIDI/ADPCM AUDIO CODEC | |||
|
◁ |
VLSI
Solution y
VS1103b
VS1103B
7. OPERATION
7.4.3 Adding a RIFF Header
To make your IMA ADPCM ï¬le a RIFF / WAV ï¬le, you have to add a header before the actual data.
Note that 2- and 4-byte values are little-endian (lowest byte ï¬rst) in this format:
File Offset Field Name
Size Bytes
Description
0 ChunkID
4 ChunkSize
8 Format
12 SubChunk1ID
4 "RIFF"
4 F0 F1 F2 F3
4 "WAVE"
4 "fmt "
File size - 8
16 SubChunk1Size
20 AudioFormat
22 NumOfChannels
24 SampleRate
28 ByteRate
4 0x14 0x0 0x0 0x0 20
2 0x11 0x0
0x11 for IMA ADPCM
2 0x1 0x0
Mono sound
4 R0 R1 R2 R3
0x1f40 for 8 kHz
4 B0 B1 B2 B3
0xfd7 for 8 kHz
32 BlockAlign
34 BitsPerSample
36 ByteExtraData
38 ExtraData
40 SubChunk2ID
44 SubChunk2Size
48 NumOfSamples
52 SubChunk3ID
56 SubChunk3Size
2 0x0 0x1
2 0x4 0x0
2 0x2 0x0
2 0xf9 0x1
4 "fact"
4 0x4 0x0 0x0 0x0
4 S0 S1 S2 S3
4 "data"
4 D0 D1 D2 D3
0x100
4-bit ADPCM
2
Samples per block (505)
4
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 à 256 + 52
R = Fs (see Chapter 7.4.1 to see how to calculate Fs)
B
=
FsÃ256
505
S = n à 505. D = n à 256
If you know beforehand how much you are going to record, you may ï¬ll in the complete header before
any actual data. However, if you donât know how much you are going to record, you have to ï¬ll in the
header size datas F , S and D after ï¬nishing recording.
The 128 words (256 bytes) of an ADPCM block are read from SCI IN0 and written into ï¬le as follows.
The high 8 bits of SCI IN0 should be written as the ï¬rst byte to a ï¬le, then the low 8 bits. Note that this
is contrary to the default operation of some 16-bit microcontrollers, and you may have to take extra care
to do this right.
A way to see if you have written the ï¬le in the right way is to check bytes 2 and 3 (the ï¬rst byte counts as
byte 0) of each 256-byte block. Byte 2 should always be less than 90, and byte 3 should always be zero.
Version 1.01, 2007-09-03
39
|
▷ |