views:

156

answers:

1

How do I go about correctly playing audio files which may have a variable bitrate (and even a variable number of channels in some cases), such as ogg/vorbis?

XAudio expects this information in a WAVEFORMATEX structure on creation of the source voice, and doesn't seem to provide a means to change it for each buffer thats submitted...

+1  A: 

Unless I'm high, no audio format specifies variable output bitrate or variable number of output channels. A variable bitrate codec means that the number of bits used to encode a fixed number of samples varies. Vorbis allows for dynamically encoding the channels as well for channels that can be reproduced with simpler functions such as silence. The number of output channels remains constant, as well as the output bitrate.

Also, XAudio2 does not natively support ogg/vorbis files; it supports PCM, ADPCM, and xWMA on Windows and PCM, XMA, and xWMA on Xbox 360.

In general, for non-native formats, you have to decompress the audio yourself into the appropriate output bitrate and channel format and send that to an IXAudio2SourceVoice via IXAudio2SourceVoice::SubmitSourceBuffer.

MSN