DirectSound/DirectMusic?

Started by
3 comments, last by mrmrcoleman 18 years, 9 months ago
Hello. I need to add some sound to my application, I need to know whether it would be best to use DirectShow or DirectMusic. Here is what I need to able to do: - play short clips (wav/mp3) - some clips need to be looped - I need to be able to stop/start/restart clips when I choose - I need to be able to play more than 1 of the same clip at once Thanks for any help. Mark Coleman
Advertisement
DirectMusic is mostly used for MIDI and doesn't play mp3. To play mp3's, you use DirectShow.
I use DirectSound with ogg vorbis. Ogg handles streaming audio (without having to worry about the mp3 licensing problems) and you can use the basic directsound helper classes to play sounds pretty easily. In both cases, the sounds can be stopped, paused, restarted, etc. I'm pretty sure there's a way to play multiple instances of the same sound without having to load multiple soundbuffers, but I haven't played around with that too much.

http://www.vorbis.com/download_win.psp
Cheers for the link to the OGG SDK, Toraque. I've been looking into adding OGG support into my engine (once I get audio implemented..).

DirectSound is, thankfully, one of the simplest and most straightforward parts of the DirectX API that you'll have to deal with. The hardest part is loading the sounds from files, seriously. I'm not sure why there isn't a utility function to do so, considering the relative simplicity of the WAV format, and the fact that WAV is MS's own soudn format. There are utility functions in the DirectSound samples that allow you to load WAVs, however.

All you have to do is create a DirectSound8 device, and create a DirectSoundBuffer8. The buffer is used to hold the sound data (amazingly enough), and can be played once, looping, started, paused, reset, whatever. You can create many buffers, and most sound cards today have a lot of hardware channels (usually at least 64 channels). That means you can play 64 sounds at once without too much trouble. You can also use the DirectSound8.DuplicateSoundBuffer to create a new buffer that points to the same memory, but can be played and stopped independently of the first one.
_______________________________________________________________________Hoo-rah.
Thanks guys, DirectSound it is then.

Mark

This topic is closed to new replies.

Advertisement