Sign in to follow this  
mrmrcoleman

DirectSound/DirectMusic?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this