From 69f364a5fcfe9f31dced847cf8d945061062eea5 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 19 Nov 2015 12:26:47 -0500 Subject: [PATCH] cmMidiFilePlay.c : Fixed bug where cmMfpClock() was not using the correct dtick time. --- cmMidiFilePlay.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmMidiFilePlay.c b/cmMidiFilePlay.c index f1b0457..58cb44b 100644 --- a/cmMidiFilePlay.c +++ b/cmMidiFilePlay.c @@ -226,7 +226,9 @@ cmMfpRC_t cmMfpClock( cmMfpH_t h, unsigned dusecs ) p->cbFunc( p->userCbPtr, p->mtime, mp ); - + + unsigned atick0 = mp->atick; + ++(p->msgIdx); if( p->msgIdx >= p->msgN ) @@ -235,13 +237,16 @@ cmMfpRC_t cmMfpClock( cmMfpH_t h, unsigned dusecs ) // get the next msg to send mp = p->msgV[p->msgIdx]; + assert( mp->atick >= atick0 ); + unsigned dtick = mp->atick - atick0; + // we probably went past the actual mtime - so update etime // with the delta usecs from the msg just sent and the current time p->etime -= p->mtime; // calc the delta usecs from the message just sent to the next msg to send //p->mtime = (mp->tick - p->msgV[p->msgIdx-1]->tick) * p->microsPerTick; - p->mtime = mp->dtick * p->microsPerTick; + p->mtime = dtick * p->microsPerTick; }