Jump to content
  • Advertisement

Archived

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

moucard

making a sound play only once (until it ends)

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

The code I use to play my segment is this:
m_pPerformance->PlaySegmentEx(m_pSegment, 0, NULL, 
DMUS_SEGF_SECONDARY, 0, 0, NULL, NULL);
   
The problem is I've assigned the sound to play on a mouse move where I check certain circumstances (whether the mouse cursor lies within a ball on the screen). It seems that the sound plays a few (2-3 times) before the check for the IsPlaying function kicks in. This I can hear because I've also assigned a button to play the sound. When I use the button you can hear the sound with a (relatively) low volume, playing only once. When I use the mouse move event to trigger the sound the volume is louder and a faint echo can't be distinguished. I've tried bypassing the IsPlaying method with a static bool like this:
static bool bSoundPlays = false;
...
if (m_vBalls[i].TouchInside(cursorX, cursorY, cursorSize) 
&& !m_cSounds[1].IsPlaying() && !bSoundPlays) {
  m_cSounds[1].Play();
  bSoundPlays = true;
}
else {
  bSoundPlays = false;
}
but I still get the same effect. Can anyone help me please? edit: during the playing of one sound I want to be able to play another sound, just not the same one (same "instance"). [edited by - moucard on June 7, 2004 10:45:02 AM] [edited by - moucard on June 7, 2004 10:45:55 AM]

Share this post


Link to post
Share on other sites
Advertisement
this may not be helpful to you, but it may as well. for real-time crisp sound you''re going to need to tackle direct sound.

other than having to work with a sound buffer its not much more difficult and its performance is such that you''ll have less issues with it in the long run. its also worth mentioning that the interface of DSound allows alot more control of the actual sound played without any recognizable performance issues.

All of that said, i see nothing wrong with your logical construct so the problem must lie elsewhere.

Dredd
________________________________________

"To die with your sword still in its sheath is most regrettable" -- Miyomoto Musashi


Share this post


Link to post
Share on other sites
I'm using Direct Sound, am I not? I mean in DX9 the interfaces to Direct Sound and Direct Music are united. If you look at the code snippet on the third line (not the
 but the [code]) you'll see that I'm using a DirectSound interface.


[edited by - moucard on June 7, 2004 12:52:48 PM]

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!