Browse Source

Debugged cmDspMidiFilePlay and Added cmDspScFol

master
kevin 11 years ago
parent
commit
0f776fb762
2 changed files with 261 additions and 61 deletions
  1. 231
    50
      dsp/cmDspKr.c
  2. 30
    11
      dsp/cmDspPgmKr.c

+ 231
- 50
dsp/cmDspKr.c View File

@@ -37,6 +37,8 @@
37 37
 #include "cmAudioFile.h"
38 38
 #include "cmMidiFile.h"
39 39
 #include "cmTimeLine.h"
40
+#include "cmScore.h"
41
+#include "cmProc4.h"
40 42
 
41 43
 enum
42 44
 {
@@ -232,6 +234,8 @@ struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx )
232 234
 
233 235
 
234 236
 //==========================================================================================================================================
237
+// Time Line UI Object
238
+
235 239
 enum
236 240
 {
237 241
   kTlFileTlId,
@@ -239,8 +243,11 @@ enum
239 243
   kSelTlId,
240 244
   kAudFnTlId,
241 245
   kMidiFnTlId,
242
-  kBegSmpIdxTlId,
243
-  kEndSmpIdxTlId
246
+  kBegAudSmpIdxTlId,
247
+  kEndAudSmpIdxTlId,
248
+  kBegMidiSmpIdxTlId,
249
+  kEndMidiSmpIdxTlId
250
+
244 251
 };
245 252
 
246 253
 cmDspClass_t _cmTimeLineDC;
@@ -255,23 +262,27 @@ cmDspInst_t*  _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
255 262
 {
256 263
   cmDspVarArg_t args[] =
257 264
   {
258
-    { "tlfile",  kTlFileTlId,    0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl,   "Time line file." },
259
-    { "path",    kAudPathTlId,   0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl,   "Audio path"    },
260
-    { "sel",     kSelTlId,       0, 0, kInDsvFl   | kInDsvFl   | kOutDsvFl  | kUIntDsvFl,   "Selected marker id."},
261
-    { "afn",     kAudFnTlId,     0, 0, kOutDsvFl  | kStrzDsvFl,   "Selected Audio file." },
262
-    { "mfn",     kMidiFnTlId,    0, 0, kOutDsvFl  | kStrzDsvFl,   "Selected MIDI file." },
263
-    { "bsi",     kBegSmpIdxTlId, 0, 0, kOutDsvFl  | kUIntDsvFl,   "Begin audio sample index."},
264
-    { "esi",     kEndSmpIdxTlId, 0, 0, kOutDsvFl  | kUIntDsvFl,   "End audio sample index."},
265
+    { "tlfile",  kTlFileTlId,         0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl,   "Time line file." },
266
+    { "path",    kAudPathTlId,        0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl,   "Audio path"    },
267
+    { "sel",     kSelTlId,            0, 0, kInDsvFl   | kInDsvFl   | kOutDsvFl  | kUIntDsvFl,   "Selected marker id."},
268
+    { "afn",     kAudFnTlId,          0, 0, kOutDsvFl  | kStrzDsvFl,   "Selected Audio file." },
269
+    { "mfn",     kMidiFnTlId,         0, 0, kOutDsvFl  | kStrzDsvFl,   "Selected MIDI file." },
270
+    { "absi",     kBegAudSmpIdxTlId,  0, 0, kOutDsvFl  | kIntDsvFl,   "Begin audio sample index."},
271
+    { "aesi",     kEndAudSmpIdxTlId,  0, 0, kOutDsvFl  | kIntDsvFl,   "End audio sample index."},
272
+    { "mbsi",     kBegMidiSmpIdxTlId, 0, 0, kOutDsvFl  | kIntDsvFl,   "Begin MIDI sample index."},
273
+    { "mesi",     kEndMidiSmpIdxTlId, 0, 0, kOutDsvFl  | kIntDsvFl,   "End MIDI sample index."},
265 274
     { NULL, 0, 0, 0, 0 }
266 275
   };
267 276
 
268 277
   cmDspTimeLine_t* p = cmDspInstAlloc(cmDspTimeLine_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
269 278
   
270
-  cmDspSetDefaultUInt(  ctx, &p->inst,  kSelTlId,       0, cmInvalidId);
271
-  cmDspSetDefaultStrcz( ctx, &p->inst,  kAudFnTlId,     NULL, "");
272
-  cmDspSetDefaultStrcz( ctx, &p->inst,  kMidiFnTlId,     NULL, "");
273
-  cmDspSetDefaultUInt(  ctx, &p->inst,  kBegSmpIdxTlId, 0, cmInvalidIdx);
274
-  cmDspSetDefaultUInt(  ctx, &p->inst,  kEndSmpIdxTlId, 0, cmInvalidIdx);
279
+  cmDspSetDefaultUInt( ctx, &p->inst,  kSelTlId,           0, cmInvalidId);
280
+  cmDspSetDefaultStrcz(ctx, &p->inst,  kAudFnTlId,         NULL, "");
281
+  cmDspSetDefaultStrcz(ctx, &p->inst,  kMidiFnTlId,        NULL, "");
282
+  cmDspSetDefaultInt(  ctx, &p->inst,  kBegAudSmpIdxTlId,  0, cmInvalidIdx);
283
+  cmDspSetDefaultInt(  ctx, &p->inst,  kEndAudSmpIdxTlId,  0, cmInvalidIdx);
284
+  cmDspSetDefaultInt(  ctx, &p->inst,  kBegMidiSmpIdxTlId, 0, cmInvalidIdx);
285
+  cmDspSetDefaultInt(  ctx, &p->inst,  kEndMidiSmpIdxTlId, 0, cmInvalidIdx);
275 286
 
276 287
   // create the UI control
277 288
   cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kAudPathTlId,kSelTlId);
@@ -328,8 +339,8 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
328 339
           {
329 340
             assert(op->typeId == kMarkerTlId);
330 341
 
331
-            cmDspSetUInt(ctx, inst, kBegSmpIdxTlId, op->begSmpIdx );
332
-            cmDspSetUInt(ctx, inst, kEndSmpIdxTlId, op->begSmpIdx + op->durSmpCnt );
342
+            cmDspSetInt(ctx, inst, kBegAudSmpIdxTlId,  op->begSmpIdx );
343
+            cmDspSetInt(ctx, inst, kEndAudSmpIdxTlId,  op->begSmpIdx + op->durSmpCnt );
333 344
             
334 345
             // locate the audio file assoc'd with the marker
335 346
             cmTlAudioFile_t* afp;
@@ -339,7 +350,12 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
339 350
             // locate the midi file assoc'd with the marker
340 351
             cmTlMidiFile_t* mfp;
341 352
             if((mfp = cmTimeLineMidiFileAtTime(p->tlH,op->seqId,op->seqSmpIdx)) != NULL )
353
+            {
354
+              cmDspSetInt(ctx, inst, kBegMidiSmpIdxTlId, op->seqSmpIdx - mfp->obj.seqSmpIdx );
355
+              cmDspSetInt(ctx, inst, kEndMidiSmpIdxTlId, op->seqSmpIdx + op->durSmpCnt - mfp->obj.seqSmpIdx );
356
+
342 357
               cmDspSetStrcz(ctx, inst, kMidiFnTlId, mfp->fn );
358
+            }
343 359
           }
344 360
           
345 361
         }
@@ -371,12 +387,7 @@ struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx )
371 387
 }
372 388
 
373 389
 //==========================================================================================================================================
374
-
375
-//
376
-//
377
-//  Read files created by this object with the Octave function cmTextFile().
378
-//
379
-//
390
+// MIDI File Player
380 391
 
381 392
 enum
382 393
 {
@@ -395,9 +406,10 @@ typedef struct
395 406
 {
396 407
   cmDspInst_t   inst;
397 408
   cmMidiFileH_t mfH;  
398
-  unsigned      msgIdx;     // current midi file msg index
399
-  unsigned      bsi;
400
-  unsigned      esi;
409
+  unsigned      curMsgIdx;     // current midi file msg index
410
+  int           csi;           // current sample index
411
+  int           bsi;           // starting sample index
412
+  int           esi;           // ending sample index
401 413
   unsigned      startSymId;
402 414
   unsigned      stopSymId;
403 415
   unsigned      contSymId;
@@ -416,11 +428,11 @@ cmDspInst_t*  _cmDspMidiFilePlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, u
416 428
 {
417 429
   cmDspVarArg_t args[] =
418 430
   {
419
-    { "fn",     kFnMfId,     0, 0, kInDsvFl  | kStrzDsvFl   | kReqArgDsvFl, "File name"},
431
+    { "fn",     kFnMfId,     0, 0, kInDsvFl  | kStrzDsvFl, "File name"},
420 432
     { "sel",    kSelMfId,    0, 0, kInDsvFl  | kSymDsvFl,  "start | stop | continue" },
421
-    { "bsi",    kBsiMfId,    0, 0, kInDsvFl  | kUIntDsvFl, "Starting sample." },
422
-    { "esi",    kEsiMfId,    0, 0, kInDsvFl  | kUIntDsvFl, "Ending sample."},
423
-    { "status", kStatusMfId, 0, 0, kOutDsvFl | kUIntDsvFl, "Status value output" },
433
+    { "bsi",    kBsiMfId,    0, 0, kInDsvFl  | kIntDsvFl, "Starting sample." },
434
+    { "esi",    kEsiMfId,    0, 0, kInDsvFl  | kIntDsvFl, "Ending sample."},
435
+    { "status", kStatusMfId, 0, 0, kOutDsvFl | kIntDsvFl, "Status value output" },
424 436
     { "d0",     kD0MfId,     0, 0, kOutDsvFl | kUIntDsvFl, "Data byte 0" },
425 437
     { "d1",     kD1MfId,     0, 0, kOutDsvFl | kUIntDsvFl, "Data byte 1" },
426 438
     { NULL, 0, 0, 0, 0 }
@@ -428,14 +440,19 @@ cmDspInst_t*  _cmDspMidiFilePlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, u
428 440
 
429 441
   cmDspMidiFilePlay_t* p = cmDspInstAlloc(cmDspMidiFilePlay_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
430 442
 
431
-  cmDspSetDefaultUInt(  ctx, &p->inst,  kStatusMfId, 0, 0);
432
-  cmDspSetDefaultUInt(  ctx, &p->inst,  kD0MfId,     0, 0);
433
-  cmDspSetDefaultUInt(  ctx, &p->inst,  kD1MfId,     0, 0);
434
-
435 443
   p->startSymId = cmSymTblRegisterStaticSymbol(ctx->stH,"start");
436 444
   p->stopSymId  = cmSymTblRegisterStaticSymbol(ctx->stH,"stop");
437 445
   p->contSymId  = cmSymTblRegisterStaticSymbol(ctx->stH,"continue");
438 446
   p->mfH        = cmMidiFileNullHandle;
447
+
448
+  cmDspSetDefaultStrcz( ctx, &p->inst, kFnMfId,   NULL, "");
449
+  cmDspSetDefaultSymbol(ctx, &p->inst,  kSelMfId,    p->stopSymId);
450
+  cmDspSetDefaultInt(   ctx, &p->inst,  kBsiMfId,    0, 0);
451
+  cmDspSetDefaultInt(   ctx, &p->inst,  kEsiMfId,    0, 0);
452
+  cmDspSetDefaultUInt(  ctx, &p->inst,  kStatusMfId, 0, 0);
453
+  cmDspSetDefaultUInt(  ctx, &p->inst,  kD0MfId,     0, 0);
454
+  cmDspSetDefaultUInt(  ctx, &p->inst,  kD1MfId,     0, 0);
455
+
439 456
   return &p->inst;
440 457
 }
441 458
 
@@ -453,10 +470,9 @@ unsigned _cmDspMidiFilePlaySeekMsgIdx( cmDspCtx_t* ctx, cmDspMidiFilePlay_t* p,
453 470
   unsigned                 i;
454 471
   unsigned                 n     = cmMidiFileMsgCount(p->mfH);
455 472
   const cmMidiTrackMsg_t** a     = cmMidiFileMsgArray(p->mfH);
456
-  double                   srate = cmDspSampleRate(ctx);
457 473
 
458 474
   for(i=0; i<n; ++i)
459
-    if( floor(a[i]->dtick*srate) > smpIdx )
475
+    if( a[i]->dtick > smpIdx )
460 476
       break;
461 477
 
462 478
   return i==n ? cmInvalidIdx : i;
@@ -464,18 +480,27 @@ unsigned _cmDspMidiFilePlaySeekMsgIdx( cmDspCtx_t* ctx, cmDspMidiFilePlay_t* p,
464 480
 
465 481
 cmDspRC_t _cmDspMidiFilePlayOpen(cmDspCtx_t* ctx, cmDspInst_t* inst )
466 482
 {
467
-  cmDspRC_t        rc = kOkDspRC;
468
-  const cmChar_t*  fn = cmDspStrcz(inst,kFnMfId);
483
+  cmDspRC_t            rc = kOkDspRC;
484
+  const cmChar_t*      fn = cmDspStrcz(inst,kFnMfId);
469 485
   cmDspMidiFilePlay_t* p  = (cmDspMidiFilePlay_t*)inst;
470 486
 
487
+  if( fn==NULL || strlen(fn)==0 )
488
+    return rc;
489
+
471 490
   if( cmMidiFileOpen( fn, &p->mfH, ctx->cmCtx ) != kOkFileRC )
472 491
     rc = cmErrMsg(&inst->classPtr->err, kInstResetFailDspRC, "MIDI file open failed.");
473 492
   else
474 493
   {
475
-    p->msgIdx    = 0;
476
-    p->bsi       = cmDspUInt(inst,kBsiMfId);
477
-    p->esi       = cmDspUInt(inst,kEsiMfId);
478
-    cmMidiFileTickToMicros(p->mfH);
494
+    p->curMsgIdx = 0;
495
+    p->bsi       = cmDspInt(inst,kBsiMfId);
496
+    p->esi       = cmDspInt(inst,kEsiMfId);
497
+    p->csi       = 0;
498
+
499
+    // force the first msg to occurr one quarter note into the file
500
+    cmMidiFileSetDelay(p->mfH, cmMidiFileTicksPerQN(p->mfH) );
501
+
502
+    // convert midi msg times to absolute time in samples
503
+    cmMidiFileTickToSamples(p->mfH,cmDspSampleRate(ctx),true);
479 504
   }
480 505
   return rc;
481 506
 }
@@ -489,16 +514,32 @@ cmDspRC_t _cmDspMidiFilePlayReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDs
489 514
 
490 515
 cmDspRC_t _cmDspMidiFilePlayExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
491 516
 {
492
-  cmDspRC_t        rc = kOkDspRC;
493
-  cmDspMidiFilePlay_t* p  = (cmDspMidiFilePlay_t*)inst;
494
-
495
-  double   srate = cmDspSampleRate(ctx);
496
-  unsigned sPc   = cmDspSamplesPerCycle(ctx);
517
+  cmDspRC_t            rc  = kOkDspRC;
518
+  cmDspMidiFilePlay_t* p   = (cmDspMidiFilePlay_t*)inst;
519
+  unsigned             sPc = cmDspSamplesPerCycle(ctx);
497 520
 
521
+  if( cmDspSymbol(inst,kSelMfId) != p->stopSymId )
522
+  {
523
+    const cmMidiTrackMsg_t** mpp   = cmMidiFileMsgArray(p->mfH);
524
+    unsigned                 msgN  = cmMidiFileMsgCount(p->mfH);
498 525
   
499
-  
500
-    
526
+    for(; p->curMsgIdx < msgN && p->csi <= mpp[p->curMsgIdx]->dtick  &&  mpp[p->curMsgIdx]->dtick < (p->csi + sPc); ++p->curMsgIdx )
527
+    {
528
+      const cmMidiTrackMsg_t* mp = mpp[p->curMsgIdx];
529
+      switch( mp->status )
530
+      {
531
+        case kNoteOnMdId:
532
+        case kCtlMdId:
533
+          cmDspSetUInt(ctx,inst, kD1MfId,     mp->u.chMsgPtr->d1);
534
+          cmDspSetUInt(ctx,inst, kD0MfId,     mp->u.chMsgPtr->d0);
535
+          cmDspSetUInt(ctx,inst, kStatusMfId, mp->status);
536
+          break;
537
+      }
538
+    }
539
+  }
501 540
 
541
+  p->csi += sPc;
542
+  
502 543
   return rc;
503 544
 }
504 545
 
@@ -518,12 +559,13 @@ cmDspRC_t _cmDspMidiFilePlayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDsp
518 559
       {
519 560
         if( cmDspSymbol(inst,kSelMfId)==p->startSymId ) 
520 561
         {
521
-          _cmDspMidiFilePlaySeekMsgIdx(ctx, p, cmDspUInt(inst,kBsiMfId) );
562
+          p->csi       = cmDspInt(inst,kBsiMfId);
563
+          p->curMsgIdx = _cmDspMidiFilePlaySeekMsgIdx(ctx, p, p->csi );
522 564
         }
523 565
         break;
524 566
       }
525
-  }
526 567
 
568
+  }
527 569
   return kOkDspRC;
528 570
 }
529 571
 
@@ -541,3 +583,142 @@ struct cmDspClass_str* cmMidiFilePlayClassCons( cmDspCtx_t* ctx )
541 583
 
542 584
   return &_cmMidiFilePlayDC;
543 585
 }
586
+
587
+//==========================================================================================================================================
588
+enum
589
+{
590
+  kFnSfId,
591
+  kWndCntSfId,
592
+  kWndMsSfId,
593
+  kIndexSfId,
594
+  kStatusSfId,
595
+  kD0SfId,
596
+  kD1SfId,
597
+  kOutSfId
598
+};
599
+
600
+cmDspClass_t _cmScFolDC;
601
+
602
+typedef struct
603
+{
604
+  cmDspInst_t inst;
605
+  cmScFol*    sfp;
606
+  cmScH_t     scH;
607
+} cmDspScFol_t;
608
+
609
+cmDspInst_t*  _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
610
+{
611
+  cmDspVarArg_t args[] =
612
+  {
613
+    { "fn",    kFnSfId,     0, 0, kInDsvFl | kStrzDsvFl   | kReqArgDsvFl,   "Score file." },
614
+    { "wndcnt",kWndCntSfId, 0, 0, kInDsvFl | kUIntDsvFl,                    "Event window element count." },
615
+    { "wndms", kWndMsSfId,  0, 0, kInDsvFl | kUIntDsvFl,                    "Event window length milliseconds."},
616
+    { "index", kIndexSfId,  0, 0, kInDsvFl | kUIntDsvFl,                    "Tracking start location."},
617
+    { "status",kStatusSfId, 0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI status byte"},
618
+    { "d0",    kD0SfId,     0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI data byte 0"},
619
+    { "d1",    kD1SfId,     0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI data byte 1"},
620
+    { "out",   kOutSfId,    0, 0, kOutDsvFl| kUIntDsvFl,                    "Current score index."},
621
+    { NULL,    0,           0, 0, 0, NULL }
622
+  };
623
+
624
+  cmDspScFol_t* p;
625
+
626
+  if((p = cmDspInstAlloc(cmDspScFol_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl)) == NULL )
627
+    return NULL;
628
+  
629
+
630
+  p->sfp = cmScFolAlloc(ctx->cmProcCtx, NULL, 0, 0, 0, cmScNullHandle );
631
+
632
+  cmDspSetDefaultUInt( ctx, &p->inst,  kWndCntSfId,     0,    10);
633
+  cmDspSetDefaultUInt( ctx, &p->inst,  kWndMsSfId,      0,  5000);
634
+  cmDspSetDefaultUInt( ctx, &p->inst,  kIndexSfId,      0,     0);  
635
+  cmDspSetDefaultUInt( ctx, &p->inst,  kOutSfId,        0,     0);
636
+
637
+  return &p->inst;
638
+}
639
+
640
+cmDspRC_t _cmDspScFolFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
641
+{
642
+  cmDspScFol_t* p = (cmDspScFol_t*)inst;
643
+  cmScFolFree(&p->sfp);
644
+  cmScoreFinalize(&p->scH);
645
+  return kOkDspRC;
646
+}
647
+
648
+cmDspRC_t _cmDspScFolOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
649
+{
650
+  const cmChar_t* fn;
651
+  cmDspScFol_t* p  = (cmDspScFol_t*)inst;
652
+
653
+  if((fn = cmDspStrcz(inst,kFnSfId)) == NULL || strlen(fn)==0 )
654
+    return cmErrMsg(&inst->classPtr->err, kInvalidArgDspRC, "No score file name supplied.");
655
+
656
+  if( cmScoreInitialize(ctx->cmCtx, &p->scH, fn, NULL, NULL ) != kOkScRC )
657
+    return cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Unable to open the score '%s'.",fn);
658
+
659
+  return kOkDspRC;
660
+}
661
+
662
+cmDspRC_t _cmDspScFolReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
663
+{
664
+  cmDspRC_t     rc = kOkDspRC;
665
+  cmDspScFol_t* p  = (cmDspScFol_t*)inst;
666
+  rc               = cmDspApplyAllDefaults(ctx,inst);
667
+
668
+  if((rc = _cmDspScFolOpenScore(ctx,inst)) != kOkDspRC )
669
+    return rc;
670
+
671
+  if( cmScoreIsValid(p->scH) )
672
+    if( cmScFolInit(p->sfp, cmDspSampleRate(ctx), cmDspUInt(inst,kWndCntSfId), cmDspUInt(inst,kWndMsSfId), p->scH) != cmOkRC )
673
+      rc = cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Internal score follower allocation failed.");
674
+
675
+  return rc;  
676
+}
677
+
678
+
679
+cmDspRC_t _cmDspScFolRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
680
+{ 
681
+  cmDspRC_t     rc = kOkDspRC;
682
+  cmDspScFol_t* p  = (cmDspScFol_t*)inst;
683
+
684
+  if((rc = cmDspSetEvent(ctx,inst,evt)) == kOkDspRC && p->sfp != NULL )
685
+  {
686
+    switch( evt->dstVarId )
687
+    {
688
+      case kIndexSfId:
689
+        if( cmScFolReset( p->sfp, cmDspUInt(inst,kIndexSfId) ) != cmOkRC )
690
+          cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Score follower reset to score index '%i' failed.");
691
+        break;
692
+
693
+      case kStatusSfId:
694
+        {
695
+          unsigned idx = cmScFolExec(p->sfp, ctx->cycleCnt, cmDspUInt(inst,kStatusSfId), cmDspUInt(inst,kD0SfId), cmDspUInt(inst,kD1SfId));
696
+          if( idx != cmInvalidIdx )
697
+            cmDspSetUInt(ctx,inst,kOutSfId,idx);
698
+        }
699
+        break;
700
+
701
+      case kFnSfId:
702
+        _cmDspScFolOpenScore(ctx,inst);
703
+        break;
704
+    }
705
+  }
706
+
707
+  return rc;
708
+}
709
+
710
+struct cmDspClass_str* cmScFolClassCons( cmDspCtx_t* ctx )
711
+{
712
+  cmDspClassSetup(&_cmScFolDC,ctx,"ScFol",
713
+    NULL,
714
+    _cmDspScFolAlloc,
715
+    _cmDspScFolFree,
716
+    _cmDspScFolReset,
717
+    NULL,
718
+    _cmDspScFolRecv,
719
+    NULL,NULL,
720
+    "Score Follower");
721
+
722
+  return &_cmScFolDC;
723
+}
724
+

+ 30
- 11
dsp/cmDspPgmKr.c View File

@@ -39,12 +39,19 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
39 39
   cmDspRC_t       rc      = kOkDspRC;
40 40
   const cmChar_t* tlFn    = "/home/kevin/src/cmgv/src/gv/data/tl7.js";
41 41
   const cmChar_t* audPath = "/home/kevin/media/audio/20110723-Kriesberg/Audio Files";
42
+  const cmChar_t* scFn    = "/home/kevin/src/cmgv/src/gv/data/mod2.csv";
43
+
44
+  cmDspInst_t* sci =  cmDspSysAllocInst(h,"Scalar", "ScIdx",  5, kNumberDuiId, 0.0,  10000.0, 1.0,  0.0);
45
+
46
+  cmDspInst_t* tlp  = cmDspSysAllocInst(h,"TimeLine",    "tl",  2, tlFn, audPath );
47
+  cmDspInst_t* php  = cmDspSysAllocInst(h,"Phasor",      NULL,  0 );
48
+  cmDspInst_t* wtp  = cmDspSysAllocInst(h,"WaveTable",   NULL,  2, cmDspSysSampleRate(h), 0 );
49
+  cmDspInst_t* pts  = cmDspSysAllocInst(h,"PortToSym",   NULL,  1, "start" );
50
+  cmDspInst_t* mfp  = cmDspSysAllocInst(h,"MidiFilePlay",NULL,  0 );
51
+  cmDspInst_t* sfp  = cmDspSysAllocInst(h,"ScFol",       NULL,  1, scFn );
52
+  cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",    NULL,  1, 0 );
53
+  cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",    NULL,  1, 1 );
42 54
 
43
-  cmDspInst_t* tlp  = cmDspSysAllocInst(h,"TimeLine",   "tl",  2, tlFn, audPath );
44
-  cmDspInst_t* php  = cmDspSysAllocInst(h,"Phasor",   NULL,  0 );
45
-  cmDspInst_t* wtp  = cmDspSysAllocInst(h,"WaveTable",NULL,  2, cmDspSysSampleRate(h), 0 );
46
-  cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 0 );
47
-  cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 1 );
48 55
 
49 56
 
50 57
   cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL,   1, ">" );
@@ -57,13 +64,25 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
57 64
   cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" );    // wt  -> aout1
58 65
 
59 66
   
60
-  cmDspSysInstallCb(h, tlp, "afn", prp, "in", NULL );
61
-  cmDspSysInstallCb(h, tlp, "afn", wtp, "fn", NULL );
62
-  cmDspSysInstallCb(h, tlp, "bsi", wtp, "beg", NULL );
63
-  cmDspSysInstallCb(h, tlp, "esi", wtp, "end", NULL );
67
+  cmDspSysInstallCb(h, tlp, "afn",  prp, "in",  NULL );
68
+  cmDspSysInstallCb(h, tlp, "mfn",  prp, "in", NULL );
69
+  cmDspSysInstallCb(h, tlp, "sel",  prp, "in", NULL );
70
+
71
+  cmDspSysInstallCb(h, tlp, "absi", wtp, "beg", NULL );
72
+  cmDspSysInstallCb(h, tlp, "aesi", wtp, "end", NULL );
73
+  cmDspSysInstallCb(h, tlp, "afn",  wtp, "fn",  NULL );
74
+
75
+  cmDspSysInstallCb(h, tlp, "mbsi", mfp, "bsi", NULL );
76
+  cmDspSysInstallCb(h, tlp, "mesi", mfp, "esi", NULL );
77
+  cmDspSysInstallCb(h, tlp, "mfn",  mfp, "fn", NULL );
78
+  cmDspSysInstallCb(h, tlp, "mfn",  pts, "start", NULL );
79
+  cmDspSysInstallCb(h, pts, "out",  mfp, "sel", NULL );
64 80
 
65
-  cmDspSysInstallCb(h, tlp, "mfn", prp, "in", NULL );
66
-  cmDspSysInstallCb(h, tlp, "sel", prp, "in", NULL );
81
+  cmDspSysInstallCb(h, mfp, "status", sfp, "status", NULL );
82
+  cmDspSysInstallCb(h, mfp, "d0",     sfp, "d0",     NULL );
83
+  cmDspSysInstallCb(h, mfp, "d1",     sfp, "d1",     NULL );
84
+  cmDspSysInstallCb(h, sci, "val",    sfp, "index",  NULL );
85
+  cmDspSysInstallCb(h, sfp, "out",    prp, "in",     NULL );
67 86
 
68 87
   return rc;
69 88
 }

Loading…
Cancel
Save