Tremor documentation | Tremor version 1.0 - 20020403

# Decoding

All libivorbisdec decoding routines are declared in "ivorbisfile.h".

After initialization, decoding audio is as simple as calling ov_read(). This function works similarly to reading from a normal file using `read()`.

However, a few differences are worth noting:

## multiple stream links

A Vorbis stream may consist of multiple sections (called links) that encode differing numbers of channels or sample rates. It is vitally important to pay attention to the link numbers returned by ov_read and handle audio changes that may occur at link boundaries. Such multi-section files do exist in the wild and are not merely a specification curiosity.

## returned data amount

ov_read does not attempt to completely fill a large, passed in data buffer; it merely guarantees that the passed back data does not overflow the passed in buffer size. Large buffers may be filled by iteratively looping over calls to ov_read (incrementing the buffer pointer) until the original buffer is filled.

## file cursor position

Vorbis files do not necessarily start at a sample number or time offset of zero. Do not be surprised if a file begins at a positive offset of several minutes or hours, such as would happen if a large stream (such as a concert recording) is chopped into multiple seperate files.

function | purpose
ov_read | This function makes up the main chunk of a decode loop. It takes an OggVorbis_File structure, which must have been initialized by a previous call to `ov_open()`.

copyright © 2002 Xiph.org | Ogg Vorbis
Tremor documentation | Tremor version 1.0 - 20020403