Jump to content
  • Advertisement


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


Looping sounds in directx

This topic is 5276 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

I have a spaceship that makes a thrusting sound, and I only want the sound to restart after it''s finished playing through. The way I have it now, it keeps starting from the beginning of the sound no matter what, even if it''s already playing. I either need a good way to check if the sound is playing or if there''s something built in to directx that plays it only if its not currently playing that''d be even better. Thanks

Share this post

Link to post
Share on other sites
I created a sound class that holds all the information for that sound as well as a bit(boolean) that is set while it is playing. You can also create an event that is thrown passing the Class Instance ID(another property I have) so when its done playing the event is thrown and the boolean is reset.

This way the sound can be checked if its "playing" already and not start again.

Hope that helps.

Share this post

Link to post
Share on other sites
I''m going by the DirectX 7 release, but I believe its all pretty much the same with version 8 & 9...

1) You need to ask the (secondary)sound buffer in question what it''s current state is. There should be a method on the interface called "->GetStatus". You pass it a DWORD variable( its address to be precise!) and you test that against DSBSTATUS_PLAYING.

2) So...

DWORD status;


// the sound buffer obviously isn''t playing...
// play the sound...

...have a good look in the SDK docs for more info should you need it.

Share this post

Link to post
Share on other sites

  • 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!