cmTimeLine.c : Updates to use amicro instead of dticks in MIDI msgs.
This commit is contained in:
parent
17bbae66a8
commit
a142123bd8
@ -530,16 +530,14 @@ cmTlRC_t _cmTlAllocRecd2(
|
|||||||
tp->flags = 0;
|
tp->flags = 0;
|
||||||
tp->text = NULL;
|
tp->text = NULL;
|
||||||
|
|
||||||
|
//printf("%9i %9i %9i %9i\n",tp->begSmpIdx,tp->durSmpCnt,refPtr==NULL?0:refPtr->obj->seqSmpIdx, tp->seqSmpIdx);
|
||||||
|
|
||||||
op->obj = tp;
|
op->obj = tp;
|
||||||
op->mem = mem;
|
op->mem = mem;
|
||||||
op->memByteCnt = byteCnt;
|
op->memByteCnt = byteCnt;
|
||||||
op->next = NULL;
|
op->next = NULL;
|
||||||
op->prev = NULL;
|
op->prev = NULL;
|
||||||
|
|
||||||
|
|
||||||
//if( seqId == 4 )
|
|
||||||
// printf("seq:%i id:%i type:%i accum:%i ref:%i offs:%i %f\n",seqId, tp->uid, tp->typeId, tp->seqSmpIdx, refPtr==NULL?-1:refPtr->obj->uid, begSmpIdx, begSmpIdx/(96000.0*60.0) );
|
|
||||||
|
|
||||||
_cmTlInsertAfter(p, _cmTlFindRecdBefore(p,op), op );
|
_cmTlInsertAfter(p, _cmTlFindRecdBefore(p,op), op );
|
||||||
|
|
||||||
|
|
||||||
@ -651,6 +649,8 @@ cmTlRC_t _cmTlProcMidiFile( _cmTl_t* p, _cmTlObj_t* op, cmMidiFileH_t mfH )
|
|||||||
const cmMidiTrackMsg_t** mapp = cmMidiFileMsgArray(mfH);
|
const cmMidiTrackMsg_t** mapp = cmMidiFileMsgArray(mfH);
|
||||||
unsigned mi = 0;
|
unsigned mi = 0;
|
||||||
_cmTlObj_t* refOp = op;
|
_cmTlObj_t* refOp = op;
|
||||||
|
double smpPerMicro = p->srate / 1000000.0;
|
||||||
|
unsigned begSmpIdx0 = 0;
|
||||||
mfp->noteOnCnt = 0;
|
mfp->noteOnCnt = 0;
|
||||||
|
|
||||||
// for each midi message
|
// for each midi message
|
||||||
@ -658,29 +658,27 @@ cmTlRC_t _cmTlProcMidiFile( _cmTl_t* p, _cmTlObj_t* op, cmMidiFileH_t mfH )
|
|||||||
{
|
{
|
||||||
_cmTlObj_t* meop = NULL;
|
_cmTlObj_t* meop = NULL;
|
||||||
const cmMidiTrackMsg_t* mp = mapp[mi];
|
const cmMidiTrackMsg_t* mp = mapp[mi];
|
||||||
|
int begSmpIdx = mp->amicro * smpPerMicro;
|
||||||
int begSmpIdx = mp->dtick;
|
|
||||||
int durSmpCnt = 0;
|
int durSmpCnt = 0;
|
||||||
unsigned midiTrkMsgByteCnt = cmMidiFilePackTrackMsgBufByteCount( mp );
|
unsigned midiTrkMsgByteCnt = cmMidiFilePackTrackMsgBufByteCount( mp );
|
||||||
unsigned recdByteCnt = sizeof(cmTlMidiEvt_t) + midiTrkMsgByteCnt;
|
unsigned recdByteCnt = sizeof(cmTlMidiEvt_t) + midiTrkMsgByteCnt;
|
||||||
|
|
||||||
//if( mfp->obj.seqId==4 && mi<=25 )
|
|
||||||
// printf("%s: bsi:%9i acc:%f smp acc:%f min %s\n", mp->status == kNoteOnMdId?"non":" ", begSmpIdx, accum, accum / (p->srate * 60),cmStringNullGuard(mfp->obj.name));
|
|
||||||
|
|
||||||
// count the note-on messages
|
// count the note-on messages
|
||||||
if( cmMidiIsNoteOn(mp->status) )
|
if( cmMidiIsNoteOn(mp->status) )
|
||||||
{
|
{
|
||||||
durSmpCnt = mp->u.chMsgPtr->durTicks;
|
durSmpCnt = mp->u.chMsgPtr->durMicros * smpPerMicro;
|
||||||
++mfp->noteOnCnt;
|
++mfp->noteOnCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cmMidiIsCtl(mp->status) && cmMidiIsSustainPedal(mp->status,mp->u.chMsgPtr->d0) )
|
if( cmMidiIsCtl(mp->status) && cmMidiIsSustainPedal(mp->status,mp->u.chMsgPtr->d0) )
|
||||||
durSmpCnt = mp->u.chMsgPtr->durTicks;
|
durSmpCnt = mp->u.chMsgPtr->durMicros * smpPerMicro;
|
||||||
|
|
||||||
// allocate the generic time-line object record
|
// allocate the generic time-line object record
|
||||||
if((rc = _cmTlAllocRecd2(p, NULL, refOp, begSmpIdx, durSmpCnt, kMidiEvtTlId, mfp->obj.seqId, recdByteCnt, &meop)) != kOkTlRC )
|
if((rc = _cmTlAllocRecd2(p, NULL, refOp, begSmpIdx-begSmpIdx0, durSmpCnt, kMidiEvtTlId, mfp->obj.seqId, recdByteCnt, &meop)) != kOkTlRC )
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
|
|
||||||
|
begSmpIdx0 = begSmpIdx;
|
||||||
|
|
||||||
assert( meop != NULL );
|
assert( meop != NULL );
|
||||||
|
|
||||||
cmTlMidiEvt_t* mep = _cmTimeLineMidiEvtObjPtr(p,meop->obj);
|
cmTlMidiEvt_t* mep = _cmTimeLineMidiEvtObjPtr(p,meop->obj);
|
||||||
@ -731,7 +729,7 @@ cmTlRC_t _cmTlAllocMidiFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmCh
|
|||||||
unsigned durSmpCnt = floor(cmMidiFileDurSecs(mfH)*p->srate);
|
unsigned durSmpCnt = floor(cmMidiFileDurSecs(mfH)*p->srate);
|
||||||
|
|
||||||
// convert the midi file from delta ticks to delta samples
|
// convert the midi file from delta ticks to delta samples
|
||||||
cmMidiFileTickToSamples(mfH,p->srate,false);
|
//cmMidiFileTickToSamples(mfH,p->srate,false);
|
||||||
|
|
||||||
// assign note durations to all note-on msg's
|
// assign note durations to all note-on msg's
|
||||||
cmMidiFileCalcNoteDurations(mfH);
|
cmMidiFileCalcNoteDurations(mfH);
|
||||||
@ -757,6 +755,7 @@ cmTlRC_t _cmTlAllocMidiFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmCh
|
|||||||
|
|
||||||
op->obj->text = mp->fn;
|
op->obj->text = mp->fn;
|
||||||
|
|
||||||
|
|
||||||
// insert the events in the midi file as individual time line objects
|
// insert the events in the midi file as individual time line objects
|
||||||
if((rc = _cmTlProcMidiFile(p, op, mfH)) != kOkTlRC )
|
if((rc = _cmTlProcMidiFile(p, op, mfH)) != kOkTlRC )
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
@ -778,8 +777,6 @@ cmTlRC_t _cmTlAllocMidiFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmCh
|
|||||||
|
|
||||||
cmTlRC_t _cmTlAllocMarkerRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmChar_t* refIdStr, int begSmpIdx, unsigned durSmpCnt, unsigned seqId, const cmChar_t* text, unsigned bar, const cmChar_t* sectionStr, unsigned markerTypeId, cmTlObj_t* refObjPtr )
|
cmTlRC_t _cmTlAllocMarkerRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmChar_t* refIdStr, int begSmpIdx, unsigned durSmpCnt, unsigned seqId, const cmChar_t* text, unsigned bar, const cmChar_t* sectionStr, unsigned markerTypeId, cmTlObj_t* refObjPtr )
|
||||||
{
|
{
|
||||||
assert( refObjPtr != NULL );
|
|
||||||
|
|
||||||
cmTlRC_t rc = kOkTlRC;
|
cmTlRC_t rc = kOkTlRC;
|
||||||
_cmTlObj_t* op = NULL;
|
_cmTlObj_t* op = NULL;
|
||||||
const cmChar_t* textStr = text==NULL ? "" : text;
|
const cmChar_t* textStr = text==NULL ? "" : text;
|
||||||
|
Loading…
Reference in New Issue
Block a user