Archived

This topic is now archived and is closed to further replies.

curtmax_0

Question about DirectSound

Recommended Posts

Is there a way to play a DSound buffer at more place than once, or do you have to create a separate buffer for the same sound and copy the data just to play the same sound more than once at the same time?

Share this post


Link to post
Share on other sites
<< Is there a way to play a DSound buffer at more place than once, or do you have to create a separate buffer for the same sound and copy the data just to play the same sound more than once at the same time? >>

I had that problem when I made my Vazteroids game. I''m pretty sure you have to use an additional sound buffer if you want to mix the same sound. For example, if you have an explosion sound that plays for 4 seconds, and you play the sound, to play the same sound 2 seconds later, you''ll need another sound buffer with the same sound loaded in order for DirectSound to mix them both.

I wrote a demo that plays nine different sounds from nine different buffers, using the keys 1 to 9. You can hold down a key and the sound must complete before starting to play again. If you can figure out how to "mix" the same sound from the same buffer, let me know.

DirectSound Demo source DirectSound Demo EXE

Phil P








Share this post


Link to post
Share on other sites
You have to use a separate sound buffer for each instance of the sound. When you call the Play method, the sound starts playing at the current position of the play cursor. If the sound is already playing, it just continues to play.

Share this post


Link to post
Share on other sites