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
       fl =  mp->dtick == 0;        
655
       fl =  mp->dtick == 0;        
656
     }
656
     }
657
       
657
       
658
-
659
     accum += dtick * p->srate / 1000000;
658
     accum += dtick * p->srate / 1000000;
660
 
659
 
661
     //int      begSmpIdx         = floor(accum_micros * p->srate / 1000000);
660
     //int      begSmpIdx         = floor(accum_micros * p->srate / 1000000);
958
   return p->srate;
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
 cmTlObj_t* cmTimeLineNextObj( cmTlH_t h, cmTlObj_t* tp, unsigned seqId )
989
 cmTlObj_t* cmTimeLineNextObj( cmTlH_t h, cmTlObj_t* tp, unsigned seqId )
962
 {
990
 {
963
   _cmTl_t* p = _cmTlHandleToPtr(h);
991
   _cmTl_t* p = _cmTlHandleToPtr(h);
1036
   return cmTimeLineMarkerObjPtr(h,op);
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
 cmTlMidiFile_t*  cmTimeLineMidiFileObjPtr(  cmTlH_t h, cmTlObj_t* op )
1084
 cmTlMidiFile_t*  cmTimeLineMidiFileObjPtr(  cmTlH_t h, cmTlObj_t* op )
1041
 {
1085
 {
1474
 
1518
 
1475
   r->msgId       = kInsertMsgTlId;
1519
   r->msgId       = kInsertMsgTlId;
1476
   r->objId       = tp->uid;
1520
   r->objId       = tp->uid;
1477
-  r->parentObjId = *parentIdPtr;
1521
+  //r->parentObjId = *parentIdPtr;
1478
   r->seqId       = tp->seqId;
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
   r->srate       = 0;
1527
   r->srate       = 0;
1484
-  r->midiTrkMsg  = NULL;
1485
-  r->textStr     = NULL;
1486
-
1528
+  //r->midiTrkMsg  = NULL;
1529
+  //r->textStr     = NULL;
1530
+  /*
1487
   switch( tp->typeId )
1531
   switch( tp->typeId )
1488
   {
1532
   {
1489
     case kMidiFileTlId:
1533
     case kMidiFileTlId:
1515
     default:
1559
     default:
1516
       { assert(0); }
1560
       { assert(0); }
1517
   }
1561
   }
1518
-
1562
+  */
1519
   return rc;
1563
   return rc;
1520
 }
1564
 }
1521
 
1565
 

+ 6
- 9
app/cmTimeLine.h View File

111
   bool            cmTimeLineIsValid( cmTlH_t h );
111
   bool            cmTimeLineIsValid( cmTlH_t h );
112
   double          cmTimeLineSampleRate( cmTlH_t h );
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
   // Return the object following 'p' assigned to 'seqId'.
118
   // Return the object following 'p' assigned to 'seqId'.
115
   // If 'p' is NULL then return the first object assigned to seqId.
119
   // If 'p' is NULL then return the first object assigned to seqId.
116
   // If 'seqId' is set to cmInvalidId then return the next object on any seq.
120
   // If 'seqId' is set to cmInvalidId then return the next object on any seq.
126
   cmTlAudioEvt_t*  cmTlNextAudioEvtObjPtr(  cmTlH_t h, cmTlObj_t* op, unsigned seqId );
130
   cmTlAudioEvt_t*  cmTlNextAudioEvtObjPtr(  cmTlH_t h, cmTlObj_t* op, unsigned seqId );
127
   cmTlMarker_t*    cmTlNextMarkerObjPtr(    cmTlH_t h, cmTlObj_t* op, unsigned seqId );
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
   // Cast a genereic cmTlObj_t pointer to a specificy type.
135
   // Cast a genereic cmTlObj_t pointer to a specificy type.
131
   cmTlMidiFile_t*  cmTimeLineMidiFileObjPtr(  cmTlH_t h, cmTlObj_t* op );
136
   cmTlMidiFile_t*  cmTimeLineMidiFileObjPtr(  cmTlH_t h, cmTlObj_t* op );
195
   {
200
   {
196
     cmTlUiMsgTypeId_t       msgId;         // See cmTlUiMsgTypeId_t.
201
     cmTlUiMsgTypeId_t       msgId;         // See cmTlUiMsgTypeId_t.
197
     unsigned                objId;         // Set to cmTlObj_t.uid
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
     double                  srate;         // Only valid with kInitMsgTlId.
204
     double                  srate;         // Only valid with kInitMsgTlId.
205
     unsigned                seqCnt;        // Only valid with kInitMsgTlId.
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
   } cmTlUiMsg_t;
206
   } cmTlUiMsg_t;
210
 
207
 
211
   // Decode a serialized cmTlObj_t as passed to the cmTlCb_t listener
208
   // Decode a serialized cmTlObj_t as passed to the cmTlCb_t listener

Loading…
Cancel
Save