DirectMusic: Why wont it stop? :(

Started by
10 comments, last by Anri 19 years, 4 months ago
I'm trying to do a very simple thing in DirectMusic. I have a segment playing, and I want it to stop after a certain time, so I do this:

// Get the current time
REFERENCE_TIME RefTime;
m_pPerformance->GetTime(&RefTime, NULL);
m_pPerformance->StopEx(m_pSegmentState, RefTime + TransitionTime, DMUS_SEGF_GRID | DMUS_SEGF_REFTIME);

TransitionTime is 44000000, which should be about 4.4 seconds. Unfortunately, it just doesn't stop. I can either get it to stop instantly or not at all, by playing around with the values I pass in for time.
Advertisement
What is the duration of the segment?
At the moment I'm testing it with a short segment (4 bars) which is set to loop constantly. Does it invalidate the stop command when the segment loops? Surely if I'm stopping the segment state then it shouldn't matter about loops etc.
Have you tried using the Segment::SetLoopPoints() method in some way?
No, the segments are authored in DirectMusic Producer, so the loop points are set that way. What I want is for the segment to loop continuously until the stop function is called, which makes the segment stop after a certain amount of time.
Oh, sorry. I misunderstood =)

Hmm, have you set the correct parameters in ::PlaySegemntEx().
For instance, is the SegmentState supplied in the function call and have you used the correct flags for timing and boundaries.
My PlaySegmentEx function just looks like this:

m_pPerformance->PlaySegmentEx(m_pSegment, NULL, NULL, DMUS_SEGF_BEAT, 0, &SegmentState, NULL, NULL);


It just plays the segment on the next beat boundary.
Although my most recent experiance with DirectMusic was using the DX.7 SDK, this sounds like you may have another function call that you have called to start the damn thing playing again AFTER you have this code put a stop to it. Make sure it isn't an error on your side, before looking at DirectMusic.

Having a look at the DX 9 SDK, I have notice that your "StopEX" method call uses a flag to indicate Reference Time, but the flags for your "PlaySegmentEx" call does not. This is new to me, but I suggest you look into it.

Also, in the "PlaySegmentEx" call, you use "&SegmentState" but you use "m_pSegmentState" for the "StopEx" call. Makes me wonder if you are stopping the wrong segment...

I hope this helps.

Languages; C, Java. Platforms: Android, Oculus Go, ZX Spectrum, Megadrive.

Website: Mega-Gen Garage

The reference time flags just indicate that the time you've specified to play / stop is in reference time. There isn't another call starting the segment again, I've stripped the whole thing down so basically I press a button to start a segment, then another one to call the stop function. Also, I call PlaySegmentEx with &SegmentState then use that to get the DX8 interface with ::QueryInterface, which goes into m_pSegmentState.
Hmm. Okay, lets go back to the discussion on "setting loop points"...

Did you specifically put those in yourself using the DMP(DirectMusic Producer) or did the DMP automatically put them in itself?

If you put them in - take them out and see what happens. If the DMP did it - then the loop points shouldn't be the problem.

Also, when you stop the segment playing, you could immedietly after reset the counter back to 0. Though, I expect you have already tried this...

Languages; C, Java. Platforms: Android, Oculus Go, ZX Spectrum, Megadrive.

Website: Mega-Gen Garage

This topic is closed to new replies.

Advertisement