Pausing a MIDI
I''ve been having a few problems getting a MIDI to pause lately. Here''s my play and pause code respectively. I can get it to sort of pause and unpause. However unpausing make it start at different positions to where it was stopped. Sometimes before where I stopped it or after where it gets stopped, depending on how I play around with the variables. Any help would be greatly appreciated.
void CDirectMidi::play()
{
if(!m_bInitialized) //Exit if not ready.
return;
if(m_pMIDIsegment && m_pPerformance) //No bad pointers.
{
m_pMIDIsegment->SetRepeats(0xFFFFFFFF); //Repeat multiple times.
m_pPerformance->PlaySegment(m_pMIDIsegment, 0, 0, &m_pSegmentState); //Play.
m_pMIDIsegment->GetStartPoint(&mtStart);
}
}
void CDirectMidi::pause()
{
MUSIC_TIME mtNow;
if (!m_bInitialized) //Exit if not ready.
return;
if (m_pPerformance)
{
m_pPerformance->Stop(NULL, NULL, 0, 0); //Stop playing.
m_pPerformance->GetTime(NULL, &mtNow);
mtOffset = mtOffset + (mtNow - mtStart);
m_pMIDIsegment->SetStartPoint(mtOffset);
//m_pSegmentState->Release();
}
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement