Browse Source

cmDspKr.c : cmRecdPlay object only records/plays segments when it recieves

a perfect match to the start of the record/playback segment. Segments
which are specified between the last received score location and the
current location are skipped.
master
kevin 10 years ago
parent
commit
8e0fb864e4
1 changed files with 45 additions and 40 deletions
  1. 45
    40
      dsp/cmDspKr.c

+ 45
- 40
dsp/cmDspKr.c View File

@@ -2370,6 +2370,7 @@ cmDspClass_t _cmNanoMapDC;
2370 2370
 typedef struct
2371 2371
 {
2372 2372
   cmDspInst_t inst;
2373
+
2373 2374
 } cmDspNanoMap_t;
2374 2375
 
2375 2376
 cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 )
@@ -2382,6 +2383,8 @@ cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, un
2382 2383
 
2383 2384
 void _cmDspNanoMapPgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm )
2384 2385
 {
2386
+  cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
2387
+
2385 2388
   unsigned i;
2386 2389
         
2387 2390
   for(i=0; i<kMidiChCnt; ++i)
@@ -2427,7 +2430,7 @@ cmDspRC_t _cmDspNanoMapReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
2427 2430
 
2428 2431
 cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
2429 2432
 {
2430
-  //cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
2433
+  cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
2431 2434
 
2432 2435
   switch( evt->dstVarId )
2433 2436
   {
@@ -2438,7 +2441,7 @@ cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
2438 2441
 
2439 2442
     case kStatusNmId:
2440 2443
       {
2441
-        unsigned status = cmDsvGetUInt(evt->valuePtr);
2444
+        unsigned status = cmDsvGetUInt(evt->valuePtr);        
2442 2445
         if( (status & 0xf0) == kNoteOnMdId )
2443 2446
         {
2444 2447
           unsigned d0 = cmDspUInt(inst,kD0NmId);
@@ -2446,6 +2449,7 @@ cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
2446 2449
           status = (status & 0xf0) + ch;
2447 2450
           cmDspSetUInt(ctx,inst,kStatusNmId,status);
2448 2451
         }
2452
+       
2449 2453
       }
2450 2454
       break;
2451 2455
 
@@ -2501,7 +2505,7 @@ typedef struct
2501 2505
   unsigned    offSymId;
2502 2506
   unsigned    audioOutBaseId;
2503 2507
   unsigned    chCnt;
2504
-  unsigned    scLocIdx;
2508
+  //unsigned    scLocIdx;
2505 2509
 } cmDspRecdPlay_t;
2506 2510
 
2507 2511
 cmDspRC_t _cmDspRecdPlayParseRsrc( cmDspCtx_t* ctx, cmDspInst_t* inst, cmRecdPlay* rcdply )
@@ -2519,7 +2523,7 @@ cmDspRC_t _cmDspRecdPlayParseRsrc( cmDspCtx_t* ctx, cmDspInst_t* inst, cmRecdPla
2519 2523
     path = "";
2520 2524
 
2521 2525
   cmJsonH_t     jsH = cmDspSysPgmRsrcHandle(ctx->dspH);
2522
-  cmJsonNode_t* jnp = cmJsonFindValue(jsH,"recdPlay",NULL, kStringTId);
2526
+  cmJsonNode_t* jnp = cmJsonFindValue(jsH,"recdPlay",NULL, kArrayTId);
2523 2527
 
2524 2528
   if( jnp == NULL || cmJsonIsArray(jnp)==false )
2525 2529
   {
@@ -2585,7 +2589,7 @@ cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
2585 2589
 
2586 2590
   cmDspRecdPlay_t* p = (cmDspRecdPlay_t*)inst;
2587 2591
 
2588
-  p->scLocIdx = 0;
2592
+  //p->scLocIdx = 0;
2589 2593
 
2590 2594
 
2591 2595
   if((fn = cmDspStrcz(inst,kFnPrId)) == NULL || strlen(fn)==0 )
@@ -2614,7 +2618,7 @@ cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
2614 2618
     if((rc = _cmDspRecdPlayParseRsrc(ctx,inst,p->rcdply)) != kOkDspRC )
2615 2619
       rc = cmDspInstErr(ctx,inst,kInstResetFailDspRC,"The 'recdplay' segment pre-load failed.");
2616 2620
 
2617
-    p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
2621
+    //p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
2618 2622
 
2619 2623
   }
2620 2624
 
@@ -2657,7 +2661,7 @@ cmDspInst_t*  _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2657 2661
   p->offSymId       = cmSymTblId(ctx->stH,"off");
2658 2662
   p->audioOutBaseId = audioOutBase;
2659 2663
   p->chCnt          = chCnt;
2660
-  p->scLocIdx       = 0;
2664
+  //p->scLocIdx       = 0;
2661 2665
 
2662 2666
   printf("0 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
2663 2667
 
@@ -2753,7 +2757,7 @@ cmDspRC_t _cmDspRecdPlayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
2753 2757
       {
2754 2758
         printf("rewind\n");
2755 2759
         cmRecdPlayRewind(p->rcdply);
2756
-        p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
2760
+        //p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
2757 2761
       }
2758 2762
       else
2759 2763
         if( cmDspSymbol(inst,kCmdPrId) == p->offSymId )
@@ -2777,45 +2781,46 @@ cmDspRC_t _cmDspRecdPlayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
2777 2781
         if( endScLocIdx < cmDspUInt(inst,kScInitLocIdxPrId) )
2778 2782
           break;
2779 2783
 
2780
-        for(; p->scLocIdx<=endScLocIdx; p->scLocIdx+=1)
2781
-        {
2782
-          cmScoreLoc_t*    loc = cmScoreLoc(p->scH, p->scLocIdx );
2783
-          cmScoreMarker_t* mp  = loc->markList;
2784
+        cmScoreLoc_t*    loc = cmScoreLoc(p->scH, endScLocIdx );
2785
+        if( loc == NULL )
2786
+          break;
2784 2787
 
2785
-          for(; mp!=NULL; mp=mp->link)
2786
-            switch( mp->markTypeId )
2787
-            {
2788
-              case kRecdBegScMId:
2789
-                printf("recd-beg %s\n",cmSymTblLabel(ctx->stH,mp->labelSymId));
2790
-                cmRecdPlayBeginRecord(p->rcdply, mp->labelSymId );
2791
-                break;
2788
+        cmScoreMarker_t* mp  = loc->markList;
2789
+
2790
+        for(; mp!=NULL; mp=mp->link)
2791
+          switch( mp->markTypeId )
2792
+          {
2793
+            case kRecdBegScMId:
2794
+              printf("recd-beg %s\n",cmSymTblLabel(ctx->stH,mp->labelSymId));
2795
+              cmRecdPlayBeginRecord(p->rcdply, mp->labelSymId );
2796
+              break;
2792 2797
                 
2793
-              case kRecdEndScMId:
2794
-                printf("recd-end %s\n",cmSymTblLabel(ctx->stH,mp->labelSymId));
2795
-                cmRecdPlayEndRecord(p->rcdply, mp->labelSymId );
2796
-                break;
2798
+            case kRecdEndScMId:
2799
+              printf("recd-end %s\n",cmSymTblLabel(ctx->stH,mp->labelSymId));
2800
+              cmRecdPlayEndRecord(p->rcdply, mp->labelSymId );
2801
+              break;
2797 2802
                 
2798
-              case kPlayBegScMId:
2799
-                printf("play-beg\n");
2800
-                cmRecdPlayBeginPlay(p->rcdply, mp->labelSymId );
2801
-                break;
2803
+            case kPlayBegScMId:
2804
+              printf("play-beg\n");
2805
+              cmRecdPlayBeginPlay(p->rcdply, mp->labelSymId );
2806
+              break;
2802 2807
 
2803
-              case kPlayEndScMId:
2804
-                printf("play-end\n");
2805
-                cmRecdPlayEndPlay(p->rcdply, mp->labelSymId );
2806
-                break;
2808
+            case kPlayEndScMId:
2809
+              printf("play-end\n");
2810
+              cmRecdPlayEndPlay(p->rcdply, mp->labelSymId );
2811
+              break;
2807 2812
 
2808
-              case kFadeScMId:
2809
-                printf("fade-beg\n");
2810
-                cmRecdPlayBeginFade(p->rcdply, mp->labelSymId, cmDspDouble(inst,kFadeRatePrId) );
2811
-                break;
2813
+            case kFadeScMId:
2814
+              printf("fade-beg\n");
2815
+              cmRecdPlayBeginFade(p->rcdply, mp->labelSymId, cmDspDouble(inst,kFadeRatePrId) );
2816
+              break;
2812 2817
 
2813
-              default:
2814
-                break;
2815
-            }
2816
-        }
2818
+            default:
2819
+              break;
2820
+          }
2821
+        
2817 2822
 
2818
-        p->scLocIdx = endScLocIdx+1;
2823
+        //p->scLocIdx = endScLocIdx+1;
2819 2824
       }
2820 2825
       break;
2821 2826
   }

Loading…
Cancel
Save