Browse Source

cmDspKr.c MIDI file player now emits time tag. Changes related to score follower development

master
kevin 12 years ago
parent
commit
3a5ab6f36c
1 changed files with 29 additions and 18 deletions
  1. 29
    18
      dsp/cmDspKr.c

+ 29
- 18
dsp/cmDspKr.c View File

@@ -513,7 +513,8 @@ enum
513 513
   kEsiMfId,
514 514
   kStatusMfId,
515 515
   kD0MfId,
516
-  kD1MfId
516
+  kD1MfId,
517
+  kSmpIdxMfId
517 518
 };
518 519
 
519 520
 cmDspClass_t _cmMidiFilePlayDC;
@@ -546,11 +547,12 @@ cmDspInst_t*  _cmDspMidiFilePlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, u
546 547
   {
547 548
     { "fn",     kFnMfId,     0, 0, kInDsvFl  | kStrzDsvFl, "File name"},
548 549
     { "sel",    kSelMfId,    0, 0, kInDsvFl  | kSymDsvFl,  "start | stop | continue" },
549
-    { "bsi",    kBsiMfId,    0, 0, kInDsvFl  | kIntDsvFl, "Starting sample." },
550
-    { "esi",    kEsiMfId,    0, 0, kInDsvFl  | kIntDsvFl, "Ending sample."},
551
-    { "status", kStatusMfId, 0, 0, kOutDsvFl | kIntDsvFl, "Status value output" },
550
+    { "bsi",    kBsiMfId,    0, 0, kInDsvFl  | kIntDsvFl,  "Starting sample." },
551
+    { "esi",    kEsiMfId,    0, 0, kInDsvFl  | kIntDsvFl,  "Ending sample."},
552
+    { "status", kStatusMfId, 0, 0, kOutDsvFl | kIntDsvFl,  "Status value output" },
552 553
     { "d0",     kD0MfId,     0, 0, kOutDsvFl | kUIntDsvFl, "Data byte 0" },
553 554
     { "d1",     kD1MfId,     0, 0, kOutDsvFl | kUIntDsvFl, "Data byte 1" },
555
+    { "smpidx", kSmpIdxMfId, 0, 0, kOutDsvFl | kUIntDsvFl, "Msg time tag as a sample index." }, 
554 556
     { NULL, 0, 0, 0, 0 }
555 557
   };
556 558
 
@@ -646,6 +648,7 @@ cmDspRC_t _cmDspMidiFilePlayExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDsp
646 648
       {
647 649
         case kNoteOnMdId:
648 650
         case kCtlMdId:
651
+          cmDspSetUInt(ctx,inst, kSmpIdxMfId, mp->dtick);
649 652
           cmDspSetUInt(ctx,inst, kD1MfId,     mp->u.chMsgPtr->d1);
650 653
           cmDspSetUInt(ctx,inst, kD0MfId,     mp->u.chMsgPtr->d0);
651 654
           cmDspSetUInt(ctx,inst, kStatusMfId, mp->status);
@@ -705,11 +708,14 @@ enum
705 708
 {
706 709
   kFnSfId,
707 710
   kBufCntSfId,
708
-  kBufMsSfId,
711
+  kMinLkAhdSfId,
712
+  kMaxWndCntSfId,
713
+  kMinVelSfId,
709 714
   kIndexSfId,
710 715
   kStatusSfId,
711 716
   kD0SfId,
712 717
   kD1SfId,
718
+  kSmpIdxSfId,
713 719
   kOutSfId
714 720
 };
715 721
 
@@ -726,15 +732,18 @@ cmDspInst_t*  _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
726 732
 {
727 733
   cmDspVarArg_t args[] =
728 734
   {
729
-    { "fn",    kFnSfId,     0, 0, kInDsvFl | kStrzDsvFl   | kReqArgDsvFl,   "Score file." },
730
-    { "bufcnt",kBufCntSfId, 0, 0, kInDsvFl | kUIntDsvFl,                    "Event buffer element count." },
731
-    { "bufms", kBufMsSfId,  0, 0, kInDsvFl | kUIntDsvFl,                    "Event buffer length milliseconds."},
732
-    { "index", kIndexSfId,  0, 0, kInDsvFl | kUIntDsvFl,                    "Tracking start location."},
733
-    { "status",kStatusSfId, 0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI status byte"},
734
-    { "d0",    kD0SfId,     0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI data byte 0"},
735
-    { "d1",    kD1SfId,     0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI data byte 1"},
736
-    { "out",   kOutSfId,    0, 0, kOutDsvFl| kUIntDsvFl,                    "Current score index."},
737
-    { NULL,    0,           0, 0, 0, NULL }
735
+    { "fn",    kFnSfId,       0, 0, kInDsvFl | kStrzDsvFl   | kReqArgDsvFl,   "Score file." },
736
+    { "bufcnt",kBufCntSfId,   0, 0, kInDsvFl | kUIntDsvFl,                    "Event buffer element count." },
737
+    { "lkahd", kMinLkAhdSfId, 0, 0, kInDsvFl | kUIntDsvFl,                    "Minimum window look-ahead."},
738
+    { "wndcnt",kMaxWndCntSfId,0, 0, kInDsvFl | kUIntDsvFl,                    "Maximum window length."},
739
+    { "minvel",kMinVelSfId,   0, 0, kInDsvFl | kUIntDsvFl,                    "Minimum velocity."},
740
+    { "index", kIndexSfId,    0, 0, kInDsvFl | kUIntDsvFl,                    "Tracking start location."},
741
+    { "status",kStatusSfId,   0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI status byte"},
742
+    { "d0",    kD0SfId,       0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI data byte 0"},
743
+    { "d1",    kD1SfId,       0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI data byte 1"},
744
+    { "smpidx",kSmpIdxSfId,   0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI time tag as a sample index"},
745
+    { "out",   kOutSfId,      0, 0, kOutDsvFl| kUIntDsvFl,                    "Current score index."},
746
+    { NULL,    0,             0, 0, 0, NULL }
738 747
   };
739 748
 
740 749
   cmDspScFol_t* p;
@@ -743,10 +752,12 @@ cmDspInst_t*  _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
743 752
     return NULL;
744 753
   
745 754
 
746
-  p->sfp = cmScFolAlloc(ctx->cmProcCtx, NULL, 0, 0, 0, cmScNullHandle );
755
+  p->sfp = cmScFolAlloc(ctx->cmProcCtx, NULL, 0, cmScNullHandle, 0, 0, 0, 0 );
747 756
 
748
-  cmDspSetDefaultUInt( ctx, &p->inst,  kBufCntSfId,     0,    10);
749
-  cmDspSetDefaultUInt( ctx, &p->inst,  kBufMsSfId,      0,  5000);
757
+  cmDspSetDefaultUInt( ctx, &p->inst,  kBufCntSfId,     0,     7);
758
+  cmDspSetDefaultUInt( ctx, &p->inst,  kMinLkAhdSfId,   0,    10);
759
+  cmDspSetDefaultUInt( ctx, &p->inst,  kMaxWndCntSfId,  0,    25);
760
+  cmDspSetDefaultUInt( ctx, &p->inst,  kMinVelSfId,     0,     5);
750 761
   cmDspSetDefaultUInt( ctx, &p->inst,  kIndexSfId,      0,     0);  
751 762
   cmDspSetDefaultUInt( ctx, &p->inst,  kOutSfId,        0,     0);
752 763
 
@@ -785,7 +796,7 @@ cmDspRC_t _cmDspScFolReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
785 796
     return rc;
786 797
 
787 798
   if( cmScoreIsValid(p->scH) )
788
-    if( cmScFolInit(p->sfp, cmDspSampleRate(ctx), cmDspUInt(inst,kBufCntSfId), cmDspUInt(inst,kBufMsSfId), p->scH) != cmOkRC )
799
+    if( cmScFolInit(p->sfp, cmDspSampleRate(ctx),  p->scH, cmDspUInt(inst,kBufCntSfId), cmDspUInt(inst,kMinLkAhdSfId), cmDspUInt(inst,kMaxWndCntSfId), cmDspUInt(inst,kMinVelSfId) ) != cmOkRC )
789 800
       rc = cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Internal score follower allocation failed.");
790 801
 
791 802
   return rc;  

Loading…
Cancel
Save