Datasheet
HH
VS1053B OGG VORBIS ENCODER VSMPG
2.3 Running the VS1053b Ogg Vorbis Encoder
This chapter will describe how to load and run the Ogg Vorbis Encoder. A C language
source file has been included in this package as an example.
2.3.1 VS1053b Ogg Vorbis Encoder Registers
Register Bits Description
SCI_MODE 14 Select MIC/LINE1
12 Set to 1 when told in the instructions
1 VU meter stereo mode activation
SCI_AICTRL0 15:0 Maximum signal level, set to 0x8000 (mono) or 0x8080 (stereo)
SCI_AICTRL1 15:0 Recording gain (1024 = 1×) or 0 for automatic gain control
SCI_AICTRL2 15:0 Maximum autogain amplification (1024 = 1×, 65535 = 64×)
SCI_AICTRL3 0 W: Finish recording, set to 0
1 R: Recording finished, set to 0
2 R: There is at least one byte to read, set to 0
3 W: Input channel select (only mono profiles), 0 = left, 1 = right
7:4 W: Max samples in frame = n × 4096, 0 = no limit
15:8 R: The next data byte if available, set to 0
Before activating Ogg Vorbis recording, the user must initalize registers SCI_AICTRL0
- SCI_AICTRL3. SCI_AICTRL1 and SCI_AICTRL2 can be altered during recording.
SCI_AICTRL0 records the maximum absolute value of the signal. The maximum value
of this linear register is 0x7FFF in mono mode, or 0x7F7F in stereo mode. For more
information on how to use this register, see Chapter 2.4.1. SCI_AICTRL0 is updated
once for every Vorbis block, i.e. 10. . . 170 times per second with the current profiles.
SCI_AICTRL1 controls linear recording gain. 1024 is equal to digital gain 1 (recom-
mended for best quality), 2048 is equal to digital gain 2, and so on. If the user wants to
use automatic gain control (AGC), SCI_AICTRL1 should be set to 0. Speech applica-
tions are often better off using some AGC, as this helps to get relatively uniform speech
loudness in recordings.
SCI_AICTRL2 controls the maximum AGC gain if SCI_AICTRL1 is set to 0. This limits
amplification of noise when there is no signal. For more information on recording levels,
see Chapter 2.4.
SCI_AICTRL3 offers run-time controls, channel selection for mono input, the maximum
number of samples that are allowed in one Ogg frame with 4096 sample granularity, and
the next unread byte, if any. Normally 0 (no limit) is a good value for granularity, but
streaming applications often have maximum delay considerations, thus making limiting
necessary. Note that limiting frame size isn’t entirely accurate, so always select a maxi-
mum frame size slightly lower than your absolute upper delay limit.
Example: your samplerate is 44100 Hz and you want frame output at least every 500 ms.
Then you’ll need samples at 22100 sample intervals. Round this downwards to the clos-
est 4096 multiple, and you’ll get 16384 samples, so you’ll write 0x40 to SCI_AICTRL3.
The bitrate penalty of this example is ≈0.5 kbit/s.
For this to work your reads must be byte aligned as explained in Chapter 2.3.3.
For Vox operation controls, see Chapter 2.5.
Rev. 1.70c 2012-11-16
Page 8(39)