Using DirectX9 to play Ogg Vorbis files

Started by
3 comments, last by BEHOLDER192875 15 years, 5 months ago
How in the world can I get Windows/DirectX to play an Ogg Vorbis file? .ogg I am using Microsoft Visual C++ 2008 Studio Express. Any help would be greatly appreciated.
Advertisement
You can use either XAudio2, or the depreciated DirectSound.
I don't think that either of them provide simple functions that just plays a .ogg file, so you'll have to write the loader yourself.

This process can be much simplifyied if you go visit the theora site here and download the provided decoders. You'll need libogg and libvorbis. The documentation there should help you get started.

[size=1]Visit my website, rawrrawr.com

This GameDev article might help you. It shouldn't be too difficult to replace the OpenAL stuff with XAudio2 or Directsound code (I'd recommend XAudio2, because it's better supported and is a nicer API anyway). Basically you can't directly play it, you're going to have to use libogg and libvorbis to decode it to PCM data, then play that with some other audio API. You can stream it, or do it all in one go.
Construct (Free open-source game creator)
Here is a class for streaming ogg. You can basically cut and paste it into your project. Somewhere online I've also found a tutorial on loading a ogg into memory and using the DirectSound buffer to play it but I can't find it now.
http://www.flipcode.com/archives/Ogg_Vorbis_Player_Class.shtml

This is the site for playing the OggVorbis sound format using DirectSound, and using C++.

This topic is closed to new replies.

Advertisement