Datasheet
HH
VS1053B OGG VORBIS ENCODER VSMPG
2.3.3 Reading Ogg Vorbis Data
After Ogg Vorbis recording has been activated, registers SCI_HDAT0 and SCI_HDAT1
have new functions.
The Ogg Vorbis bitstream buffer size is 4096 16-bit words, or 8 KiB. The fill status of the
buffer can be read from SCI_HDAT1. If SCI_HDAT1 is greater than 0, you can read that
many 16-bit words from SCI_HDAT0.
If data is not read fast enough from SCI_HDAT0, the buffer overflows and returns to
empty state. A data overflow will result in an incorrect file that may be undecodable.
However, because of the large size of the bitstream buffer and the relatively slow bitrates
of Ogg Vorbis, this situation should be easy to avoid.
Ogg frames are byte aligned. Because of the 16-bit SCI interface this may be a prob-
lem for streaming applications where it is important to forward any Ogg frame as soon
as possible: the latest frame may pend upon its last byte. If transferring data with a
low delay is important, you can read whether there is one extra data byte by reading
SCI_AICTRL3 twice in a row. The result of the latter read will contain the correct data:
if bit 2 is 1, then bits 15:8 contain the odd byte. After reading the odd byte successfully,
discard bits 15:8 of the next read from SCI_HDAT0 because they contain the same data.
(NOTE: if you don’t stream or don’t need the shortest possible delay, you can ignore this
paragraph!)
If you are having trouble with receiving data, notice that all Ogg Vorbis files always begin
with the following 4 bytes: 0x4f 0x67 0x67 0x53 (the string “OggS”). If you get 0x67 0x4f
0x53 0x67 (“gOSg”) instead, you are storing the least and most significant byte in the
16-bit data words incorrectly. If you get 0x00 0x00 0x67 0x53, you have read data from
SCI_HDAT0 too soon after starting the application.
Rev. 1.70c 2012-11-16
Page 10(39)