Bladeren bron

cmDspKr.c : Added option to cmDspScFol to generate score measurements

(dyn,even,tempo,cost) as they are computed.
master
kevin 11 jaren geleden
bovenliggende
commit
b95348f047
1 gewijzigde bestanden met toevoegingen van 45 en 26 verwijderingen
  1. 45
    26
      dsp/cmDspKr.c

+ 45
- 26
dsp/cmDspKr.c Bestand weergeven

@@ -872,9 +872,9 @@ enum
872 872
 {
873 873
   kFnSfId,
874 874
   kBufCntSfId,
875
-  kMinLkAhdSfId,
876 875
   kMaxWndCntSfId,
877 876
   kMinVelSfId,
877
+  kMeasflSfId,
878 878
   kIndexSfId,
879 879
   kStatusSfId,
880 880
   kD0SfId,
@@ -883,10 +883,10 @@ enum
883 883
   kCmdSfId,
884 884
   kOutSfId,
885 885
   kRecentSfId,
886
-  kDynSfId,
887
-  kEvenSfId,
888
-  kTempoSfId,
889
-  kCostSfId,
886
+  kVlocSfId,
887
+  kVtypSfId,
888
+  kVvalSfId,
889
+  kVcostSfId,
890 890
   kSymSfId
891 891
 };
892 892
 
@@ -909,17 +909,18 @@ typedef struct cmDspScFol_str
909 909
   unsigned          printSymId;
910 910
   unsigned          quietSymId;
911 911
   unsigned          maxScLocIdx;
912
+  bool              liveFl;
912 913
 } cmDspScFol_t;
913 914
 
914 915
 cmDspInst_t*  _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
915 916
 {
916 917
   cmDspVarArg_t args[] =
917 918
   {
918
-    { "fn",    kFnSfId,       0, 0, kInDsvFl | kStrzDsvFl   | kReqArgDsvFl,   "Score file." },
919
-    { "bufcnt",kBufCntSfId,   0, 0, kInDsvFl | kUIntDsvFl,                    "Event buffer element count." },
920
-    { "lkahd", kMinLkAhdSfId, 0, 0, kInDsvFl | kUIntDsvFl,                    "Minimum window look-ahead."},
921
-    { "wndcnt",kMaxWndCntSfId,0, 0, kInDsvFl | kUIntDsvFl,                    "Maximum window length."},
922
-    { "minvel",kMinVelSfId,   0, 0, kInDsvFl | kUIntDsvFl,                    "Minimum velocity."},
919
+    { "fn",    kFnSfId,       0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl,     "Score file." },
920
+    { "bufcnt",kBufCntSfId,   0, 0, kInDsvFl | kUIntDsvFl | kOptArgDsvFl,     "Event buffer element count." },
921
+    { "wndcnt",kMaxWndCntSfId,0, 0, kInDsvFl | kUIntDsvFl | kOptArgDsvFl,     "Maximum window length."},
922
+    { "minvel",kMinVelSfId,   0, 0, kInDsvFl | kUIntDsvFl | kOptArgDsvFl,     "Minimum velocity."},
923
+    { "measfl",kMeasflSfId,   0, 0, kInDsvFl | kBoolDsvFl | kOptArgDsvFl,     "Enable measurements"},
923 924
     { "index", kIndexSfId,    0, 0, kInDsvFl | kUIntDsvFl,                    "Tracking start location."},
924 925
     { "status",kStatusSfId,   0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI status byte"},
925 926
     { "d0",    kD0SfId,       0, 0, kInDsvFl | kUIntDsvFl,                    "MIDI data byte 0"},
@@ -928,10 +929,10 @@ cmDspInst_t*  _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
928 929
     { "cmd",   kCmdSfId,      0, 0, kInDsvFl | kSymDsvFl,                     "Command input: print | quiet"},
929 930
     { "out",   kOutSfId,      0, 0, kOutDsvFl| kUIntDsvFl,                    "Maximum score location index."},
930 931
     { "recent",kRecentSfId,   0, 0, kOutDsvFl| kUIntDsvFl,                    "Most recent score location index."},
931
-    { "dyn",   kDynSfId,      0, 0, kOutDsvFl| kDoubleDsvFl,                  "Dynamic value."},
932
-    { "even",  kEvenSfId,     0, 0, kOutDsvFl| kDoubleDsvFl,                  "Evenness value."},
933
-    { "tempo", kTempoSfId,    0, 0, kOutDsvFl| kDoubleDsvFl,                  "Tempo value."},
934
-    { "cost",  kCostSfId,     0, 0, kOutDsvFl| kDoubleDsvFl,                  "Match cost value."},
932
+    { "vloc",  kVlocSfId,     0, 0, kOutDsvFl| kUIntDsvFl,                    "Score location at which the variable value becomes active."},
933
+    { "vtyp",  kVtypSfId,     0, 0, kOutDsvFl| kUIntDsvFl,                    "Variable type: 0=even=kEvenVarScId 1=dyn=kDynVarScId 2=tempo=kTempoVarScId."},
934
+    { "vval",  kVvalSfId,     0, 0, kOutDsvFl| kDoubleDsvFl,                  "Variable value."},
935
+    { "vcost", kVcostSfId,    0, 0, kOutDsvFl| kDoubleDsvFl,                  "Variable match cost value."},
935 936
     { "sym",   kSymSfId,      0, 0, kOutDsvFl| kSymDsvFl,                     "Symbol associated with a global variable which has changed value."},
936 937
     { NULL,    0,             0, 0, 0, NULL }
937 938
   };
@@ -949,15 +950,11 @@ cmDspInst_t*  _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
949 950
 
950 951
   cmDspSetDefaultUInt(   ctx, &p->inst,  kBufCntSfId,     0,     7);
951 952
   cmDspSetDefaultUInt(   ctx, &p->inst,  kMaxWndCntSfId,  0,    10);
952
-  cmDspSetDefaultUInt(   ctx, &p->inst,  kMinLkAhdSfId,   0,     3);
953 953
   cmDspSetDefaultUInt(   ctx, &p->inst,  kMinVelSfId,     0,     5);
954
+  cmDspSetDefaultBool(   ctx, &p->inst,  kMeasflSfId,     0,     0);
954 955
   cmDspSetDefaultUInt(   ctx, &p->inst,  kIndexSfId,      0,     0);  
955 956
   cmDspSetDefaultUInt(   ctx, &p->inst,  kOutSfId,        0,     0);
956 957
   cmDspSetDefaultUInt(   ctx, &p->inst,  kRecentSfId,     0,     0);
957
-  cmDspSetDefaultDouble( ctx, &p->inst,  kDynSfId,        0,     0);
958
-  cmDspSetDefaultDouble( ctx, &p->inst,  kEvenSfId,       0,     0);
959
-  cmDspSetDefaultDouble( ctx, &p->inst,  kTempoSfId,      0,     0);
960
-  cmDspSetDefaultDouble( ctx, &p->inst,  kCostSfId,       0,     0);
961 958
   
962 959
   cmDspSetDefaultSymbol(ctx,&p->inst,  kCmdSfId, p->quietSymId );
963 960
 
@@ -990,6 +987,7 @@ void _cmScFolMatcherCb( cmScMatcher* p, void* arg, cmScMatcherResult_t* rp )
990 987
       if(ap->sfp->smp->set[i].value != DBL_MAX )
991 988
       {
992 989
 
990
+        /*
993 991
         switch( ap->sfp->smp->set[i].sp->varId )
994 992
         {
995 993
           case kEvenVarScId:
@@ -1009,7 +1007,7 @@ void _cmScFolMatcherCb( cmScMatcher* p, void* arg, cmScMatcherResult_t* rp )
1009 1007
         }           
1010 1008
 
1011 1009
         cmDspSetDouble(ap->ctx,inst,kCostSfId,ap->sfp->smp->set[i].match_cost);
1012
-
1010
+        */
1013 1011
 
1014 1012
         // Set the values in the global variable storage
1015 1013
         cmDspValue_t vv,cv;
@@ -1024,6 +1022,14 @@ void _cmScFolMatcherCb( cmScMatcher* p, void* arg, cmScMatcherResult_t* rp )
1024 1022
 
1025 1023
           cmDspSetSymbol(ap->ctx,inst,kSymSfId,ap->sfp->smp->set[i].sp->symArray[j]);
1026 1024
           cmDspSetSymbol(ap->ctx,inst,kSymSfId,ap->sfp->smp->set[i].sp->costSymArray[j]);
1025
+
1026
+          if( cmDspBool(inst,kMeasflSfId) )
1027
+          {
1028
+            cmDspSetUInt(   ap->ctx, inst, kVlocSfId,  ap->sfp->smp->set[i].sp->sectArray[j]->locPtr->index);
1029
+            cmDspSetDouble( ap->ctx, inst, kVvalSfId,  ap->sfp->smp->set[i].value);
1030
+            cmDspSetDouble( ap->ctx, inst, kVcostSfId, ap->sfp->smp->set[i].match_cost);
1031
+            cmDspSetUInt(   ap->ctx, inst, kVtypSfId,  ap->sfp->smp->set[i].sp->varId);
1032
+          }
1027 1033
         }
1028 1034
 
1029 1035
 
@@ -2364,6 +2370,9 @@ cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
2364 2370
     double maxLaSecs    = cmDspDouble(inst,kMaxLaSecsPrId);
2365 2371
     double curLaSecs    = cmDspDouble(inst,kCurLaSecsPrId);
2366 2372
 
2373
+    printf("2 max la secs:%f\n",cmDspDouble(inst,kMaxLaSecsPrId));
2374
+
2375
+
2367 2376
     if((p->rcdply = cmRecdPlayAlloc(ctx->cmProcCtx, NULL, cmDspSampleRate(ctx), markerCnt, p->chCnt, initFragSecs, maxLaSecs, curLaSecs)) == NULL)
2368 2377
       return cmErrMsg(&inst->classPtr->err,kSubSysFailDspRC,"Unable to create the internal recorder-player object.");    
2369 2378
 
@@ -2393,11 +2402,11 @@ cmDspInst_t*  _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2393 2402
 
2394 2403
   cmDspRecdPlay_t* p = cmDspInstAllocV(cmDspRecdPlay_t,ctx,classPtr,instSymId,id,storeSymId,va_cnt,vl1,
2395 2404
     1,         "chs",    kChCntPrId,      0,0, kUIntDsvFl | kReqArgDsvFl,              "channel count.",
2396
-    1,         "fn",     kFnPrId,         0,0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl, "Score file." ,
2405
+    1,         "fn",     kFnPrId,         0,0, kInDsvFl   | kStrzDsvFl   | kReqArgDsvFl, "Score file." ,
2397 2406
     1,         "secs",   kSecsPrId,       0,0, kInDsvFl   | kDoubleDsvFl | kReqArgDsvFl, "Initial fragment allocation in seconds.",
2398
-    1,         "maxla",  kMaxLaSecsPrId,  0,0, kInDsvFl   | kDoubleDsvFl,              "Maximum look-ahead buffer in seconds.",
2399
-    1,         "curla",  kCurLaSecsPrId,  0,0, kInDsvFl   | kDoubleDsvFl,              "Current look-head buffer in seconds.",
2400
-    1,         "frate",  kFadeRatePrId,   0,0, kInDsvFl   | kDoubleDsvFl,              "Fade rate in dB per second.",
2407
+    1,         "maxla",  kMaxLaSecsPrId,  0,0, kInDsvFl   | kDoubleDsvFl | kReqArgDsvFl, "Maximum look-ahead buffer in seconds.",
2408
+    1,         "curla",  kCurLaSecsPrId,  0,0, kInDsvFl   | kDoubleDsvFl | kOptArgDsvFl, "Current look-head buffer in seconds.",
2409
+    1,         "frate",  kFadeRatePrId,   0,0, kInDsvFl   | kDoubleDsvFl | kOptArgDsvFl, "Fade rate in dB per second.",
2401 2410
     1,         "index",  kScLocIdxPrId,   0,0, kInDsvFl   | kUIntDsvFl,                "Score follower location index.",
2402 2411
     1,         "cmd",    kCmdPrId,        0,0, kInDsvFl   | kSymDsvFl,                 "on=reset off=stop.",
2403 2412
     chCnt,     "in",     kInAudioBasePrId,0,1, kInDsvFl   | kAudioBufDsvFl,            "Audio input",
@@ -2412,11 +2421,16 @@ cmDspInst_t*  _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2412 2421
   p->chCnt          = chCnt;
2413 2422
   p->scLocIdx       = 0;
2414 2423
 
2424
+  printf("0 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
2425
+
2415 2426
   cmDspSetDefaultDouble(ctx,&p->inst, kSecsPrId,     0.0, 10.0 );
2416 2427
   cmDspSetDefaultDouble(ctx,&p->inst, kMaxLaSecsPrId,0.0, 2.0);
2417 2428
   cmDspSetDefaultDouble(ctx,&p->inst, kCurLaSecsPrId,0.0, 0.1);
2418 2429
   cmDspSetDefaultDouble(ctx,&p->inst, kFadeRatePrId, 0.0, 1.0);
2419 2430
 
2431
+  printf("1 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
2432
+
2433
+
2420 2434
   return &p->inst;
2421 2435
 }
2422 2436
 
@@ -2433,9 +2447,11 @@ cmDspRC_t _cmDspRecdPlayFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
2433 2447
 
2434 2448
 cmDspRC_t _cmDspRecdPlayReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
2435 2449
 {
2436
-  cmDspApplyAllDefaults(ctx,inst);
2450
+  cmDspRC_t rc;
2451
+  if((rc = _cmDspRecdPlayOpenScore(ctx,inst)) == kOkDspRC )
2452
+    cmDspApplyAllDefaults(ctx,inst);
2437 2453
 
2438
-  return _cmDspRecdPlayOpenScore(ctx,inst);
2454
+  return rc;
2439 2455
 } 
2440 2456
 
2441 2457
 cmDspRC_t _cmDspRecdPlayExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
@@ -2484,6 +2500,9 @@ cmDspRC_t _cmDspRecdPlayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
2484 2500
 {
2485 2501
   cmDspRecdPlay_t* p = (cmDspRecdPlay_t*)inst;
2486 2502
 
2503
+  if( p->rcdply == NULL )
2504
+    return kOkDspRC;
2505
+
2487 2506
   cmDspSetEvent(ctx,inst,evt);
2488 2507
 
2489 2508
   switch( evt->dstVarId )

Laden…
Annuleren
Opslaan