cmMidiFilePlay.c : Updates to use amicro instead of dtick in MIDI msg.

This commit is contained in:
kevin 2015-11-19 19:12:29 -05:00
parent 8688a7f28c
commit 136cb97800

View File

@ -148,9 +148,6 @@ cmMfpRC_t cmMfpLoadHandle( cmMfpH_t h, cmMidiFileH_t mfH )
p->mtime = 0; p->mtime = 0;
p->closeFileFl= false; p->closeFileFl= false;
//if( p->msgIdx > 0 )
// p->mtime = p->msgV[0]->tick * p->microsPerTick;
return kOkMfpRC; return kOkMfpRC;
} }
@ -213,21 +210,15 @@ cmMfpRC_t cmMfpClock( cmMfpH_t h, unsigned dusecs )
// sent and the end of the time window for this mfpClock() cycle // sent and the end of the time window for this mfpClock() cycle
p->etime += dusecs; p->etime += dusecs;
//printf("init e:%i d:%i\n",p->etime, p->mtime);
// if the elapsed time (etime) since the last msg is greater or equal // if the elapsed time (etime) since the last msg is greater or equal
// to the delta time to the next msg (mtime) // to the delta time to the next msg (mtime)
while( p->etime >= p->mtime ) while( p->etime >= p->mtime )
{ {
//printf("e:%i d:%i\n",p->etime, p->mtime);
if( mp->status == kMetaStId && mp->metaId == kTempoMdId ) // send the current message
_cmMfpUpdateMicrosPerTick(p,mp->u.iVal );
p->cbFunc( p->userCbPtr, p->mtime, mp ); p->cbFunc( p->userCbPtr, p->mtime, mp );
unsigned atick0 = mp->atick; unsigned amicro = mp->amicro;
++(p->msgIdx); ++(p->msgIdx);
@ -235,18 +226,15 @@ cmMfpRC_t cmMfpClock( cmMfpH_t h, unsigned dusecs )
break; break;
// get the next msg to send // get the next msg to send
mp = p->msgV[p->msgIdx]; mp = p->msgV[p->msgIdx];
assert( mp->atick >= atick0 );
unsigned dtick = mp->atick - atick0;
// we probably went past the actual mtime - so update etime // we probably went past the actual mtime - so update etime
// with the delta usecs from the msg just sent and the current time // with the delta usecs from the msg just sent and the current time
p->etime -= p->mtime; p->etime -= p->mtime;
// calc the delta usecs from the message just sent to the next msg to send // 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->amicro - amicro;
p->mtime = dtick * p->microsPerTick;
} }