diff --git a/app/cmTimeLine.c b/app/cmTimeLine.c index eb93dd4..4348f37 100644 --- a/app/cmTimeLine.c +++ b/app/cmTimeLine.c @@ -655,7 +655,6 @@ cmTlRC_t _cmTlProcMidiFile( _cmTl_t* p, _cmTlObj_t* op, cmMidiFileH_t mfH ) fl = mp->dtick == 0; } - accum += dtick * p->srate / 1000000; //int begSmpIdx = floor(accum_micros * p->srate / 1000000); @@ -958,6 +957,35 @@ double cmTimeLineSampleRate( cmTlH_t h ) return p->srate; } +cmTlObj_t* _cmTimeLineIdToObj( _cmTl_t* p, unsigned seqId, unsigned id ) +{ + assert( seqId < p->seqCnt ); + + _cmTlObj_t* op = p->seq[seqId].first; + for(; op != NULL; op=op->next ) + if( op->obj->uid == id ) + return op->obj; + return NULL; +} + +cmTlObj_t* cmTimeLineIdToObj( cmTlH_t h, unsigned seqId, unsigned id ) +{ + _cmTl_t* p = _cmTlHandleToPtr(h); + cmTlObj_t* op = NULL; + + if( seqId != cmInvalidId ) + op = _cmTimeLineIdToObj(p,seqId,id); + else + { + for(seqId=0; seqIdseqCnt; ++seqId) + if((op = _cmTimeLineIdToObj(p,seqId,id) ) != NULL ) + break; + } + + return op; +} + + cmTlObj_t* cmTimeLineNextObj( cmTlH_t h, cmTlObj_t* tp, unsigned seqId ) { _cmTl_t* p = _cmTlHandleToPtr(h); @@ -1036,6 +1064,22 @@ cmTlMarker_t* cmTlNextMarkerObjPtr( cmTlH_t h, cmTlObj_t* op, unsigned seq return cmTimeLineMarkerObjPtr(h,op); } +cmTlObj_t* cmTlIdToObjPtr( cmTlH_t h, unsigned uid ) +{ + _cmTl_t* p = _cmTlHandleToPtr(h); + unsigned i; + for(i=0; iseqCnt; ++i) + //if( p->seq[i].first->obj->uid <= uid && uid <= p->seq[i].last->obj->uid ) + { + _cmTlObj_t* op = p->seq[i].first; + for(; op != NULL; op=op->next ) + if( op->obj->uid == uid ) + return op->obj; + } + + return NULL; +} + cmTlMidiFile_t* cmTimeLineMidiFileObjPtr( cmTlH_t h, cmTlObj_t* op ) { @@ -1474,16 +1518,16 @@ cmTlRC_t _cmTimeLineDecodeObj( const void* msg, unsigned msgByteCnt, cmTlUiMsg_ r->msgId = kInsertMsgTlId; r->objId = tp->uid; - r->parentObjId = *parentIdPtr; + //r->parentObjId = *parentIdPtr; r->seqId = tp->seqId; - r->typeId = tp->typeId; - r->begSmpIdx = tp->begSmpIdx; - r->durSmpCnt = tp->durSmpCnt; - r->label = strlen(text)==0 ? NULL : text; + //r->typeId = tp->typeId; + //r->begSmpIdx = tp->begSmpIdx; + //r->durSmpCnt = tp->durSmpCnt; + //r->label = strlen(text)==0 ? NULL : text; r->srate = 0; - r->midiTrkMsg = NULL; - r->textStr = NULL; - + //r->midiTrkMsg = NULL; + //r->textStr = NULL; + /* switch( tp->typeId ) { case kMidiFileTlId: @@ -1515,7 +1559,7 @@ cmTlRC_t _cmTimeLineDecodeObj( const void* msg, unsigned msgByteCnt, cmTlUiMsg_ default: { assert(0); } } - + */ return rc; } diff --git a/app/cmTimeLine.h b/app/cmTimeLine.h index 3d27886..95c1540 100644 --- a/app/cmTimeLine.h +++ b/app/cmTimeLine.h @@ -111,6 +111,10 @@ extern "C" { bool cmTimeLineIsValid( cmTlH_t h ); double cmTimeLineSampleRate( cmTlH_t h ); + // Given cmTlObj_t.uid return a pointer to the associated record. + // seqId is optional (dflt:cmInvalidId) + cmTlObj_t* cmTimeLineIdToObj( cmTlH_t h, unsigned seqId, unsigned uid ); + // Return the object following 'p' assigned to 'seqId'. // If 'p' is NULL then return the first object assigned to seqId. // If 'seqId' is set to cmInvalidId then return the next object on any seq. @@ -126,6 +130,7 @@ extern "C" { cmTlAudioEvt_t* cmTlNextAudioEvtObjPtr( cmTlH_t h, cmTlObj_t* op, unsigned seqId ); cmTlMarker_t* cmTlNextMarkerObjPtr( cmTlH_t h, cmTlObj_t* op, unsigned seqId ); + cmTlObj_t* cmTlIdToObjPtr( cmTlH_t h, unsigned uid ); // Cast a genereic cmTlObj_t pointer to a specificy type. cmTlMidiFile_t* cmTimeLineMidiFileObjPtr( cmTlH_t h, cmTlObj_t* op ); @@ -195,17 +200,9 @@ extern "C" { { cmTlUiMsgTypeId_t msgId; // See cmTlUiMsgTypeId_t. unsigned objId; // Set to cmTlObj_t.uid - unsigned parentObjId; // cmTlObj_t.uid of the object this object's begSmpIdx is set relative to. - unsigned seqId; // - cmTlObjTypeId_t typeId; // - int begSmpIdx; // Time relative to parent. - unsigned durSmpCnt; // Duration of the object. - const char* label; // Object label (points to memory inside the serialized msg.) + unsigned seqId; // Sequence id double srate; // Only valid with kInitMsgTlId. unsigned seqCnt; // Only valid with kInitMsgTlId. - const cmMidiTrackMsg_t* midiTrkMsg; // Only valid for typeId == kMidiEvtTlId. Internal pointers refer to memory inside the serialzed msg. buffer. - unsigned midiFileObjId; // Only valid for typeId == kMidiEvtTlId - const char* textStr; // filename for kAudioFileTlId and kMidiFileTlId, marker text for kMarkerTlId } cmTlUiMsg_t; // Decode a serialized cmTlObj_t as passed to the cmTlCb_t listener