Explorar el Código

cmDspKr.c:

1) Changed time-line to support setting data prefix path
in cmTimeLine initialization.
2) Added 'scloc' to 'ActiveMeas'.
master
kpl hace 11 años
padre
commit
b56fee2605
Se han modificado 1 ficheros con 27 adiciones y 7 borrados
  1. 27
    7
      dsp/cmDspKr.c

+ 27
- 7
dsp/cmDspKr.c Ver fichero

@@ -281,7 +281,7 @@ struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx )
281 281
 enum
282 282
 {
283 283
   kTlFileTlId,
284
-  kAudPathTlId,
284
+  kPrefixPathTlId,
285 285
   kSelTlId,
286 286
   kCursTlId,
287 287
   kResetTlId,
@@ -307,7 +307,7 @@ cmDspInst_t*  _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
307 307
   cmDspVarArg_t args[] =
308 308
   {
309 309
     { "tlfile",  kTlFileTlId,         0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl, "Time line file." },
310
-    { "path",    kAudPathTlId,        0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl, "Audio path"    },
310
+    { "path",    kPrefixPathTlId,     0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl, "Time line data file prefix path"    },
311 311
     { "sel",     kSelTlId,            0, 0, kInDsvFl   | kOutDsvFl  | kUIntDsvFl,   "Selected marker id."},
312 312
     { "curs",    kCursTlId,           0, 0, kInDsvFl   | kUIntDsvFl,  "Current audio file index."},
313 313
     { "reset",   kResetTlId,          0, 0, kInDsvFl   | kSymDsvFl,   "Resend all outputs." },
@@ -332,7 +332,7 @@ cmDspInst_t*  _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
332 332
   cmDspSetDefaultInt(  ctx, &p->inst,  kEndMidiSmpIdxTlId, 0, cmInvalidIdx);
333 333
 
334 334
   // create the UI control
335
-  cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kAudPathTlId,kSelTlId,kCursTlId);
335
+  cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kPrefixPathTlId,kSelTlId,kCursTlId);
336 336
 
337 337
   p->tlH = cmTimeLineNullHandle;
338 338
 
@@ -359,9 +359,12 @@ cmDspRC_t _cmDspTimeLineReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
359 359
   cmDspApplyAllDefaults(ctx,inst);
360 360
 
361 361
   const cmChar_t* tlFn;
362
+
363
+  const cmChar_t* tlPrePath = cmDspStrcz(inst,kPrefixPathTlId);
364
+
362 365
   if((tlFn =  cmDspStrcz(inst, kTlFileTlId )) !=  NULL )
363
-    if( cmTimeLineInitializeFromFile(ctx->cmCtx, &p->tlH, NULL, NULL, tlFn ) != kOkTlRC )
364
-      rc = cmErrMsg(&inst->classPtr->err, kInstResetFailDspRC, "Time-line file open failed.");
366
+    if( cmTimeLineInitializeFromFile(ctx->cmCtx, &p->tlH, NULL, NULL, tlFn, tlPrePath ) != kOkTlRC )
367
+        rc = cmErrMsg(&inst->classPtr->err, kInstResetFailDspRC, "Time-line file open failed.");
365 368
 
366 369
   return rc;
367 370
 }
@@ -372,7 +375,7 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
372 375
 
373 376
   switch( evt->dstVarId )
374 377
   {
375
-    case kAudPathTlId:
378
+    case kPrefixPathTlId:
376 379
       cmDspSetEvent(ctx,inst,evt);
377 380
       break;
378 381
 
@@ -1634,6 +1637,7 @@ enum
1634 1637
   kValueAmId,
1635 1638
   kCstAmId,
1636 1639
   kCmdAmId,
1640
+  kScLocAmId,
1637 1641
   kEvenAmId,
1638 1642
   kDynAmId,
1639 1643
   kTempoAmId,
@@ -1680,6 +1684,7 @@ cmDspInst_t*  _cmDspActiveMeasAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
1680 1684
     { "val",      kValueAmId,    0,0, kInDsvFl  | kDoubleDsvFl,  "Meas. Value."},
1681 1685
     { "cst",      kCstAmId,      0,0, kInDsvFl  | kDoubleDsvFl,  "Meas. Cost."},
1682 1686
     { "cmd",      kCmdAmId,      0,0, kInDsvFl  | kSymDsvFl,     "Commands:add | clear | dump | rewind"}, 
1687
+    { "scloc",    kScLocAmId,    0,0, kOutDsvFl | kUIntDsvFl,    "Score location"},
1683 1688
     { "even",     kEvenAmId,     0,0, kOutDsvFl | kDoubleDsvFl,  "Even out"},
1684 1689
     { "dyn",      kDynAmId,      0,0, kOutDsvFl | kDoubleDsvFl,  "Dyn out"},
1685 1690
     { "tempo",    kTempoAmId,    0,0, kOutDsvFl | kDoubleDsvFl,  "Tempo out"},
@@ -1697,6 +1702,7 @@ cmDspInst_t*  _cmDspActiveMeasAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
1697 1702
   p->rewindSymId= cmSymTblRegisterStaticSymbol(ctx->stH,"rewind");
1698 1703
 
1699 1704
   cmDspSetDefaultUInt(  ctx,&p->inst,kCntAmId,  0,100);
1705
+  cmDspSetDefaultUInt(  ctx,&p->inst,kScLocAmId,0,0);
1700 1706
   cmDspSetDefaultDouble(ctx,&p->inst,kEvenAmId, 0,0);
1701 1707
   cmDspSetDefaultDouble(ctx,&p->inst,kDynAmId,  0,0);
1702 1708
   cmDspSetDefaultDouble(ctx,&p->inst,kTempoAmId,0,0);
@@ -1760,7 +1766,6 @@ cmDspRC_t _cmDspActiveMeasRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEv
1760 1766
 {
1761 1767
   cmDspRC_t       rc = kOkDspRC;
1762 1768
   cmDspActiveMeas_t* p  = (cmDspActiveMeas_t*)inst;
1763
-
1764 1769
   cmDspSetEvent(ctx,inst,evt);
1765 1770
 
1766 1771
   switch( evt->dstVarId )
@@ -1768,13 +1773,21 @@ cmDspRC_t _cmDspActiveMeasRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEv
1768 1773
     case kSflocAmId:
1769 1774
       if( p->nextFullIdx != cmInvalidIdx )
1770 1775
       {
1776
+        // get the recv'd score location
1771 1777
         unsigned sflocIdx = cmDspUInt(inst,kSflocAmId);
1778
+
1779
+        unsigned prvLoc = cmInvalidIdx;
1780
+
1781
+        // for each remaining avail record
1772 1782
         for(; p->nextFullIdx < p->nextEmptyIdx; p->nextFullIdx++)
1773 1783
         {
1774 1784
           cmDspActiveMeasRecd_t* r = p->array + p->nextFullIdx;
1785
+
1786
+          // if this records score location is after the recv'd score loc then we're done
1775 1787
           if( r->loc > sflocIdx )
1776 1788
             break;
1777 1789
 
1790
+          // deterimine the records type
1778 1791
           unsigned varId = cmInvalidId;
1779 1792
           switch( r->type )
1780 1793
           {
@@ -1785,8 +1798,15 @@ cmDspRC_t _cmDspActiveMeasRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEv
1785 1798
               { assert(0); }
1786 1799
           }
1787 1800
 
1801
+          // if this score location has not yet been sent then send it now
1802
+          if( prvLoc != r->loc )
1803
+            cmDspSetUInt(ctx,inst,kScLocAmId,r->loc);
1804
+
1805
+          // transmit the records value and cost
1788 1806
           cmDspSetDouble(ctx,inst,varId,r->value);
1789 1807
           cmDspSetDouble(ctx,inst,kCostAmId,r->value);
1808
+
1809
+          prvLoc = r->loc;
1790 1810
         } 
1791 1811
         
1792 1812
 

Loading…
Cancelar
Guardar