Browse Source

cmTimeLine.c/h Removed unused fields from cmTlObj_t and added cmTimeLineIdToObjPtr()

master
kpl 12 years ago
parent
commit
f025c621ce
2 changed files with 60 additions and 19 deletions
  1. 54
    10
      app/cmTimeLine.c
  2. 6
    9
      app/cmTimeLine.h

+ 54
- 10
app/cmTimeLine.c View File

@@ -655,7 +655,6 @@ cmTlRC_t _cmTlProcMidiFile( _cmTl_t* p,  _cmTlObj_t* op, cmMidiFileH_t mfH )
655 655
       fl =  mp->dtick == 0;        
656 656
     }
657 657
       
658
-
659 658
     accum += dtick * p->srate / 1000000;
660 659
 
661 660
     //int      begSmpIdx         = floor(accum_micros * p->srate / 1000000);
@@ -958,6 +957,35 @@ double cmTimeLineSampleRate( cmTlH_t h )
958 957
   return p->srate;
959 958
 }
960 959
 
960
+cmTlObj_t* _cmTimeLineIdToObj( _cmTl_t* p, unsigned seqId, unsigned id )
961
+{
962
+  assert( seqId < p->seqCnt );
963
+
964
+  _cmTlObj_t* op = p->seq[seqId].first;
965
+  for(; op != NULL; op=op->next )
966
+    if( op->obj->uid == id )
967
+      return op->obj;
968
+  return NULL;
969
+}
970
+
971
+cmTlObj_t* cmTimeLineIdToObj( cmTlH_t h, unsigned seqId, unsigned id )
972
+{
973
+  _cmTl_t*    p  = _cmTlHandleToPtr(h);
974
+  cmTlObj_t* op = NULL;
975
+
976
+  if( seqId != cmInvalidId )
977
+    op = _cmTimeLineIdToObj(p,seqId,id);
978
+  else
979
+  {
980
+    for(seqId=0; seqId<p->seqCnt; ++seqId)
981
+      if((op = _cmTimeLineIdToObj(p,seqId,id) ) != NULL )
982
+        break;
983
+  }
984
+
985
+  return op;
986
+}
987
+
988
+
961 989
 cmTlObj_t* cmTimeLineNextObj( cmTlH_t h, cmTlObj_t* tp, unsigned seqId )
962 990
 {
963 991
   _cmTl_t* p = _cmTlHandleToPtr(h);
@@ -1036,6 +1064,22 @@ cmTlMarker_t*    cmTlNextMarkerObjPtr(    cmTlH_t h, cmTlObj_t* op, unsigned seq
1036 1064
   return cmTimeLineMarkerObjPtr(h,op);
1037 1065
 }
1038 1066
 
1067
+cmTlObj_t*       cmTlIdToObjPtr( cmTlH_t h, unsigned uid )
1068
+{
1069
+  _cmTl_t* p = _cmTlHandleToPtr(h);
1070
+  unsigned i;
1071
+  for(i=0; i<p->seqCnt; ++i)
1072
+    //if( p->seq[i].first->obj->uid <= uid && uid <= p->seq[i].last->obj->uid )
1073
+    {
1074
+      _cmTlObj_t* op = p->seq[i].first;
1075
+      for(; op != NULL; op=op->next )
1076
+        if( op->obj->uid == uid )
1077
+          return op->obj;
1078
+    }
1079
+
1080
+  return NULL;
1081
+}
1082
+
1039 1083
 
1040 1084
 cmTlMidiFile_t*  cmTimeLineMidiFileObjPtr(  cmTlH_t h, cmTlObj_t* op )
1041 1085
 {
@@ -1474,16 +1518,16 @@ cmTlRC_t  _cmTimeLineDecodeObj( const void* msg, unsigned msgByteCnt, cmTlUiMsg_
1474 1518
 
1475 1519
   r->msgId       = kInsertMsgTlId;
1476 1520
   r->objId       = tp->uid;
1477
-  r->parentObjId = *parentIdPtr;
1521
+  //r->parentObjId = *parentIdPtr;
1478 1522
   r->seqId       = tp->seqId;
1479
-  r->typeId      = tp->typeId;
1480
-  r->begSmpIdx   = tp->begSmpIdx;
1481
-  r->durSmpCnt   = tp->durSmpCnt;
1482
-  r->label       = strlen(text)==0 ? NULL : text;
1523
+  //r->typeId      = tp->typeId;
1524
+  //r->begSmpIdx   = tp->begSmpIdx;
1525
+  //r->durSmpCnt   = tp->durSmpCnt;
1526
+  //r->label       = strlen(text)==0 ? NULL : text;
1483 1527
   r->srate       = 0;
1484
-  r->midiTrkMsg  = NULL;
1485
-  r->textStr     = NULL;
1486
-
1528
+  //r->midiTrkMsg  = NULL;
1529
+  //r->textStr     = NULL;
1530
+  /*
1487 1531
   switch( tp->typeId )
1488 1532
   {
1489 1533
     case kMidiFileTlId:
@@ -1515,7 +1559,7 @@ cmTlRC_t  _cmTimeLineDecodeObj( const void* msg, unsigned msgByteCnt, cmTlUiMsg_
1515 1559
     default:
1516 1560
       { assert(0); }
1517 1561
   }
1518
-
1562
+  */
1519 1563
   return rc;
1520 1564
 }
1521 1565
 

+ 6
- 9
app/cmTimeLine.h View File

@@ -111,6 +111,10 @@ extern "C" {
111 111
   bool            cmTimeLineIsValid( cmTlH_t h );
112 112
   double          cmTimeLineSampleRate( cmTlH_t h );
113 113
 
114
+  // Given cmTlObj_t.uid return a pointer to the associated record.
115
+  // seqId is optional (dflt:cmInvalidId)
116
+  cmTlObj_t*      cmTimeLineIdToObj( cmTlH_t h, unsigned seqId, unsigned uid );
117
+
114 118
   // Return the object following 'p' assigned to 'seqId'.
115 119
   // If 'p' is NULL then return the first object assigned to seqId.
116 120
   // If 'seqId' is set to cmInvalidId then return the next object on any seq.
@@ -126,6 +130,7 @@ extern "C" {
126 130
   cmTlAudioEvt_t*  cmTlNextAudioEvtObjPtr(  cmTlH_t h, cmTlObj_t* op, unsigned seqId );
127 131
   cmTlMarker_t*    cmTlNextMarkerObjPtr(    cmTlH_t h, cmTlObj_t* op, unsigned seqId );
128 132
 
133
+  cmTlObj_t*       cmTlIdToObjPtr( cmTlH_t h, unsigned uid );
129 134
 
130 135
   // Cast a genereic cmTlObj_t pointer to a specificy type.
131 136
   cmTlMidiFile_t*  cmTimeLineMidiFileObjPtr(  cmTlH_t h, cmTlObj_t* op );
@@ -195,17 +200,9 @@ extern "C" {
195 200
   {
196 201
     cmTlUiMsgTypeId_t       msgId;         // See cmTlUiMsgTypeId_t.
197 202
     unsigned                objId;         // Set to cmTlObj_t.uid
198
-    unsigned                parentObjId;   // cmTlObj_t.uid of the object this object's begSmpIdx is set relative to.
199
-    unsigned                seqId;         // 
200
-    cmTlObjTypeId_t         typeId;        // 
201
-    int                     begSmpIdx;     // Time relative to parent.
202
-    unsigned                durSmpCnt;     // Duration of the object.
203
-    const char*             label;         // Object label (points to memory inside the serialized msg.)
203
+    unsigned                seqId;         // Sequence id
204 204
     double                  srate;         // Only valid with kInitMsgTlId.
205 205
     unsigned                seqCnt;        // Only valid with kInitMsgTlId.
206
-    const cmMidiTrackMsg_t* midiTrkMsg;    // Only valid for typeId  == kMidiEvtTlId. Internal pointers refer to memory inside the serialzed msg. buffer.
207
-    unsigned                midiFileObjId; // Only valid for typeId  == kMidiEvtTlId
208
-    const char*             textStr;       // filename for kAudioFileTlId and kMidiFileTlId, marker text for kMarkerTlId
209 206
   } cmTlUiMsg_t;
210 207
 
211 208
   // Decode a serialized cmTlObj_t as passed to the cmTlCb_t listener

Loading…
Cancel
Save