Sign in to follow this  

DirectMusic segment playing

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

Hi all, I'm having trouble with DirectMusic because it doesn't seem to know when a segment is playing or not. I'm using it for my in game sound effects and music but the problem is that a wav is played every time 2 bodies collide, and if I force an object into a corner (thus getting repeated collisions) DirectMusic plays the the wav manically and brings my framerate to a standstill. I tried to get around it by using the IsPlaying method call:
IDirectMusicSegment8* seg = segments[i]; //got from a vector
	
if (performer->IsPlaying(seg,NULL) == S_FALSE) {
	return false;
} else {    
	if (FAILED(performer->PlaySegmentEx(seg, NULL, NULL, DMUS_SEGF_SECONDARY, 0, NULL, NULL, NULL))) {
		return false;
	} else {
		return true;
	}	

But all IsPlaying seems to do is always think a segment is playing and thus never play anything, even right atthe beginning. I tried downloading and unloading the segment in there too to no avail. Any ideas what's going wrong? All I want to do is not play a sound if it's already being played thus stopping DirectMusic from going crazy. Cheers for any help, Duncan

Share this post


Link to post
Share on other sites
It looks like your function is designed to return FALSE if the segment isn't playing OR if performance object fails to play the segment. Are you sure the problem isn't with a failed call to PlaySegmentEx()?

Maybe try structuring it like this:

if(lpPerf->IsPlaying(Seg,NULL) == S_FALSE)
{
if(FAILED(lpPerf->PlaySegmentEx(Seg,NULL,NULL,DMUS_SEGF_SECONDARY,0,NULL,NULL,NULL)))
{return(FALSE);}
}


Share this post


Link to post
Share on other sites
Ah yes. I'm a spanner, dunno how I missed that logical impossibility :D

The problem is kinda half fixed now, the frame rate no longer dies (which is nice) but DirectMusic still plays the wav several times at once and somehow (I'm assuming by entering the audiopath of the backgroun music) cuts off the background music. Any idea how to get around that? I dunno how to setup/use more than the default performance audiopath!

Cheers, Duncan

Share this post


Link to post
Share on other sites
Use
IDirectMusicPerformance8::Create(Standard)AudioPath
to make a new audio path. Then just pass that to your PlaySegmentEx function (The last parameter is the audio path).

Share this post


Link to post
Share on other sites
Awesome, cheers for that. It still stops the background music playing though :/

This is what I'm doing for the effects audiopath. It can be called for every collision generated by the physics, which is quite a few when an object is stuck in a corner. Is just seem like the IsPlaying method isn't doing it's job! Surely with this logic the collision sound should stop playing before another one is allowed to start playing?:


IDirectMusicSegment8* seg = segments[i];
seg->Download(effects);

if (performer->IsPlaying(seg,0) == S_FALSE) {
return SUCCEEDED(performer->PlaySegmentEx(seg, NULL, NULL, DMUS_SEGF_SECONDARY, 0, NULL, NULL, effects));
} else {
return false;
}



The music audiopath play method is the same though I pass no flags, and obviously I pass it to the music audiopath. Any ideas?

Share this post


Link to post
Share on other sites

This topic is 4760 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.

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