BASS_OPUS_HEAD structure

Used with BASS_OPUS_StreamCreate to initialize a raw Opus decoder.

typedef struct {
    BYTE version;
    BYTE channels;
    WORD preskip;
    DWORD inputrate;
    short gain;
    BYTE mapping;
    BYTE streams;
    BYTE coupled;
    BYTE chanmap[255];
} BASS_OPUS_HEAD;

Members

versionThis should be 1, but anything below 16 will be accepted.
channelsThis is the number of output channels.
preskipThis is the number of samples to discard from the decoder output when starting playback.
inputrateThis is the sample rate of the original input (before encoding), in Hz.
gainThis is a gain in dB to be applied when decoding, stored in 8.8 fixed-point.
mappingThis is the channel mapping family, which indicates the order and semantic meaning of the output channels.
streamsThis is the total number of streams encoded in each packet.
coupledThis is the number of streams whose decoders are to be configured to produce two channels (stereo). This must be no larger than streams.
chanmapThis table defines the mapping from encoded streams to output channels. channels determines the number of elements used (the rest can be omitted).

Remarks

This structure mirrors the Ogg Opus Identification Header, minus the "OpusHead" signature. Full details can be found in the Ogg Opus spec: https://datatracker.ietf.org/doc/html/rfc7845.html#section-5.1

streams, coupled, and chanmap are not used (they can be omitted) when mapping is 0. channels is usually limited to 2 in this case, but BASS_OPUS_StreamCreate allows higher numbers to be used and automatically sets appropriate streams, coupled, and chanmap values for them. Standard channel mapping family 1 values are used for up to 8 channels, and channel mapping family 255 with sequential uncoupled channels (ie. coupled = 0) is used for any more than that.

Example

Create a stream for stereo Opus data, with default settings.
BASS_OPUS_HEAD head = { 1, 2 }; // version = 1, channels = 2, everything else = 0
HSTREAM stream = BASS_OPUS_StreamCreate(&head, 0, OpusStreamProc, 0); // create the stream

See also

BASS_OPUS_StreamCreate