cmScore.c,cmTakeSeqBldr.c : Updates to to use amicro instead of dtick field in MIDI messages.

This commit is contained in:
kevin 2015-11-19 19:11:53 -05:00
parent c8062faafe
commit 8688a7f28c
2 changed files with 11 additions and 19 deletions

View File

@ -2433,13 +2433,8 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
goto errLabel;
}
printf("secs:%f smps:%f\n",cmMidiFileDurSecs(mfH),cmMidiFileDurSecs(mfH)*96000);
//printf("secs:%f smps:%f\n",cmMidiFileDurSecs(mfH),cmMidiFileDurSecs(mfH)*96000);
// Convert the track message 'dtick' field to delta-microseconds.
cmMidiFileTickToMicros(mfH);
unsigned msgCnt = cmMidiFileMsgCount(mfH);
unsigned i;
const cmMidiTrackMsg_t** tmpp = cmMidiFileMsgArray(mfH);
@ -2474,7 +2469,7 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
unsigned d0 = 0;
unsigned d1 = 0;
unsigned metaId = 0;
double dsecs = (double)tmp->dtick / 1000000.0;
double dsecs = (double)tmp->amicro / 1000000.0;
acc_secs += dsecs;
@ -2666,10 +2661,6 @@ void cmScoreFix( cmCtx_t* ctx )
if( cmMidiFileOpen(mfn,&mfH,ctx) != kOkMfRC )
goto errLabel;
cmMidiFileTickToMicros(mfH);
cmMidiFileCalcNoteDurations(mfH);
mn = cmMidiFileMsgCount(mfH);
msg = cmMidiFileMsgArray(mfH);
@ -2699,7 +2690,7 @@ void cmScoreFix( cmCtx_t* ctx )
const cmMidiTrackMsg_t* m = msg[mi];
assert( mi+1 <= id );
secs += m->dtick/1000000.0;
secs += m->amicro/1000000.0;
if( mi+1 != id )
{
@ -2715,7 +2706,7 @@ void cmScoreFix( cmCtx_t* ctx )
++mi;
if( m->status == kNoteOnMdId )
cmCsvSetCellDouble( csvH, ci, kDSecsColScIdx, m->u.chMsgPtr->durTicks/1000000.0 );
cmCsvSetCellDouble( csvH, ci, kDSecsColScIdx, m->u.chMsgPtr->durMicros /1000000.0 );
break;
}

View File

@ -956,14 +956,15 @@ cmTsbRC_t cmTakeSeqBldrLoadTake( cmTakeSeqBldrH_t h, unsigned tlMarkUid, bool ov
}
// convert the dtick field to delta samples
cmMidiFileTickToSamples( mfH, cmTimeLineSampleRate(p->tlH), false );
//cmMidiFileTickToSamples( mfH, cmTimeLineSampleRate(p->tlH), false );
// calculate MIDI note and pedal durations (see cmMidiChMsg_t.durTicks)
cmMidiFileCalcNoteDurations( mfH );
unsigned i = 0;
unsigned n = cmMidiFileMsgCount(mfH);
const cmMidiTrackMsg_t** a = cmMidiFileMsgArray(mfH);
unsigned i = 0;
unsigned n = cmMidiFileMsgCount(mfH);
const cmMidiTrackMsg_t** a = cmMidiFileMsgArray(mfH);
double srate = cmTimeLineSampleRate(p->tlH);
// allocate and link a new take render record
cmTakeTsb_t* t = cmMemAllocZ(cmTakeTsb_t,1);
@ -1011,8 +1012,8 @@ cmTsbRC_t cmTakeSeqBldrLoadTake( cmTakeSeqBldrH_t h, unsigned tlMarkUid, bool ov
m1->scEvtIdx = stm != NULL ? stm->scEvtIdx : cmInvalidIdx;
m1->flags = stm != NULL ? stm->flags : 0;
m1->ref = m0;
m1->offsetSmp = mf0 == NULL ? 0 : mf1->dtick;
m1->durSmp = mf1->u.chMsgPtr->durTicks;
m1->offsetSmp = mf0 == NULL ? 0 : round(mf1->amicro * srate / 1000000.0);
m1->durSmp = mf1->u.chMsgPtr->durMicros * srate / 1000000.0;
m1->d0 = mf1->u.chMsgPtr->d0;
m1->d1 = mf1->u.chMsgPtr->d1;
m1->status = mf1->status;