Sign in to follow this  
f8k8

DirectMusic: Why wont it stop? :(

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Yeah, the loop points are set in DMP. The segments are set to loop infinately with the loop points at the begninning and end. These are set in DMP. What do you mean by setting the counter to 0? Which counter?

Share this post


Link to post
Share on other sites
Well, if the loop points are set by the DMP itself - then its there for a good reason. I would say that they are not the problem.

Parden me - by "setting the Counter" I mean setting the current play time of the segment back to 0. In otherwords - REWIND BACK TO THE BEGINING!

AHA! Have you set the number of times you want the song to repeat itself? This may also be a factor...

Share this post


Link to post
Share on other sites

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