using ogg in a game

Started by
4 comments, last by Marmin 18 years, 10 months ago
Hi, i want to use ogg vorbis compression in my game. I 've looked at DirectSound and DirectMusic.. should i use DirectMusic? I'm using Pascal and there are no tutorials whatsoever, as usual.
Advertisement
You probably want to use DirectShow since that is the only soundobject in DirectX that uses the filters available on your computer to play a sound-file. If you use DirectSound, you'll need to load and decompress the file yourself.
AFAIK, DirectMusic doesn't support ogg loading. Only midi and other instrumental filetypes (and of course wav).

Anyhow, I'd like to suggest that you use OpenAL for sound programming. It's a very capable and easy to use sound API and MUCH easier than the DirectX-sound APIs.
Pascal huh? Cool, not used that in years!
Well, if you can import a c dll into pascal (which I'm sure probably you can) then just use the ogg dll and documentation on the site.
If you use DirectShow you have to install the ogg codec on any machine you use ogg in... if you use the dll you can embed ogg playing into your application.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.
Quote:Original post by paulecoyote
Pascal huh? Cool, not used that in years!
Hehe.. I've heard that before :lol: The Pascal world is unfortunately a bit isolated.

Yep, I've looked into DirectSound. quote: 'If you use DirectSound, you'll need to load and decompress the file yourself' OK- maybe i'll use a wav file then instead of a ogg vorbis file. I'm cutting it 22.1 khz and 16 bit that shouldn't be a too large file.

Thanks anyway for the kind replies. :)
I'm using DirectX 8.1, what's the most used way to load a wav file into a IDirectSoundBuffer ? Do I load from a resource and then just copy into the stream? MSDN has this nice tutorial about a drum machine. I'll study this some more.
The OggVorbis library has quite a convenient interface. Most of the difficult functions of the libogg and libvorbis libraries are wrapped in a very handy OggVorbisFile-library.

The harderst part of your sound programming would probably be filling of the DirectSound buffers etc.

After you have written your WAV-capable sound engine, I would recommend to look into these libraries. The decompressing of an OGG is a matter of calling a function like ov_read() and your buffer will be filled with wave-data. (Ok, maybe a bit over-simplified, but it's not too difficult, really.)
it's WORKING! i got music in my game !!!

This topic is closed to new replies.

Advertisement