Jump to content
  • Advertisement
Sign in to follow this  
CKX

DirectSound: Buffer won't play from Position 0 sometimes

This topic is 4499 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I have made a small audio API for my future projects and I am currently implementing its logic using DirectSound. Everything works fine except one thing: Calling Play(...) on a just created (or duplicated) DirectSound buffer does not always play the buffer from the beginning. It sometimes happens that a very short fragment of the beginning is being skipped. However, this missing fragment is big enough to make short sharp sounds (e.g. shot guns, foot steps, type-writer hit) unusable. If I reduce the DirectSound hardware acceleration in Window's settings, I can get rid of this effect. But that's removing the symptoms, not the cause. Technically, I have created a static Buffer which contains data from WAV file. This buffer is used as a template - it is never played. In order to play the sound, I first duplicate this template buffer and then call Play(...) on the copy. The copy will be released again when it finished playing. In most cases, it works perfectly. But sometimes, the problem above occurs. Does anybody know this problem or has encountered this phenomenon too? Best regards, CKX

Share this post


Link to post
Share on other sites
Advertisement
It's more likely a case of latency than the sound buffer play position being incorrect. One thing you can try is to leave the mixer on during your application and stop it when you stop using direct sound. This may help reduce latency and various artifacts caused by constantly starting and stopping the mixer every time short sounds are played. To turn the mixer on, simply call the "Play" method of the primary sound buffer. And to stop it, call "Stop" method of the primary sound buffer.

If that does nothing, perhaps you could post the creation flags for the sound buffers. You could also try writing a bit of code to notify you if the sounds are, in fact, not starting at position 0.

Share this post


Link to post
Share on other sites
Hello.

I have solved my problem.

I found out that it occured only with lazy-allocated 3D-buffers (buffers created with the flags DSBCAPS_CTRL3D and DSBCAPS_LOCDEFER in combination).

When I duplicate a buffer of that kind, set the duplicate's 3D-settings and then call its Play(...)-method, DirectSounds seems not to update its global 3D-environment settings.

Hence, the sound won't be audible until I call CommitDeferredSettings() on the DirectSound 3D-listener object.

@lack o comments: I'll add primaryBuffer->Play(...) to my code since this seems to be a good advice. Thanks!

Best regards
CKX

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!