IDirectMusicSegment8* seg = segments; //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;
}
DirectMusic segment playing
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:
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
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:
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);} }
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
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
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).
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).
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?:
The music audiopath play method is the same though I pass no flags, and obviously I pass it to the music audiopath. Any ideas?
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; 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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement