Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Ogg Vorbis and WAVEFORMATEXTENSIBLE (Read 4042 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Ogg Vorbis and WAVEFORMATEXTENSIBLE


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.

Ogg Vorbis and WAVEFORMATEXTENSIBLE

Reply #1
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.