HydrogenAudio

Lossy Audio Compression => Ogg Vorbis => Ogg Vorbis - Tech => Topic started by: Zerox Millienium on 2006-08-04 17:38:14

Title: Ogg Vorbis and WAVEFORMATEXTENSIBLE
Post by: Zerox Millienium on 2006-08-04 17:38:14

How do I use Ogg Vorbis file with WAVEFORMATEXTENSIBLE?

I'm using libvorbisfile to open an ogg vorbis file and playing it using DirectSound but faced with the difficulty of filling in the information needed to be passed to the DSBUFFERDESC data structure.

I managed to use ov_info() to obtain the sampling rate (48,000Hz for quality 10 ogg) and the number of channels (usually 2 in my case). But there isn't any attribute of bits per sample (8 or 16).

Please guide me on this one, thanks. Currently, I am only capable of filling my own settings to WAVEFORMATEX data structure instead playing at 16 bits, 44,100Hz, 2 channels. This is clearly different from the ogg vorbis sample file I'm using which is of 48,000Hz. Therefore I must use WAVEFORMATEXTENSIBLE.
Title: Ogg Vorbis and WAVEFORMATEXTENSIBLE
Post by: john33 on 2006-08-07 10:58:24
If you're using ov_read, then you supply the required output bit depth - 8 or 16 bit - as a parameter to the function. Alternatively, you can use ov_read_float and the decoded output is supplied, unsurprisingly, as 32 bit floats and you can then play with that as you wish.

If you are dealing with files with more than 2 channels, how you map the output channels will depend on how the input was mapped. The internal ogg vorbis channel order is different from WAVEFORMATEXTENSIBLE. The vorbis I spec details the internal order, so far as they have been specified.