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 11 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
 typedef struct
2370
 typedef struct
2371
 {
2371
 {
2372
   cmDspInst_t inst;
2372
   cmDspInst_t inst;
2373
+
2373
 } cmDspNanoMap_t;
2374
 } cmDspNanoMap_t;
2374
 
2375
 
2375
 cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 )
2376
 cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 )
2382
 
2383
 
2383
 void _cmDspNanoMapPgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm )
2384
 void _cmDspNanoMapPgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm )
2384
 {
2385
 {
2386
+  cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
2387
+
2385
   unsigned i;
2388
   unsigned i;
2386
         
2389
         
2387
   for(i=0; i<kMidiChCnt; ++i)
2390
   for(i=0; i<kMidiChCnt; ++i)
2427
 
2430
 
2428
 cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
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
   switch( evt->dstVarId )
2435
   switch( evt->dstVarId )
2433
   {
2436
   {
2438
 
2441
 
2439
     case kStatusNmId:
2442
     case kStatusNmId:
2440
       {
2443
       {
2441
-        unsigned status = cmDsvGetUInt(evt->valuePtr);
2444
+        unsigned status = cmDsvGetUInt(evt->valuePtr);        
2442
         if( (status & 0xf0) == kNoteOnMdId )
2445
         if( (status & 0xf0) == kNoteOnMdId )
2443
         {
2446
         {
2444
           unsigned d0 = cmDspUInt(inst,kD0NmId);
2447
           unsigned d0 = cmDspUInt(inst,kD0NmId);
2446
           status = (status & 0xf0) + ch;
2449
           status = (status & 0xf0) + ch;
2447
           cmDspSetUInt(ctx,inst,kStatusNmId,status);
2450
           cmDspSetUInt(ctx,inst,kStatusNmId,status);
2448
         }
2451
         }
2452
+       
2449
       }
2453
       }
2450
       break;
2454
       break;
2451
 
2455
 
2501
   unsigned    offSymId;
2505
   unsigned    offSymId;
2502
   unsigned    audioOutBaseId;
2506
   unsigned    audioOutBaseId;
2503
   unsigned    chCnt;
2507
   unsigned    chCnt;
2504
-  unsigned    scLocIdx;
2508
+  //unsigned    scLocIdx;
2505
 } cmDspRecdPlay_t;
2509
 } cmDspRecdPlay_t;
2506
 
2510
 
2507
 cmDspRC_t _cmDspRecdPlayParseRsrc( cmDspCtx_t* ctx, cmDspInst_t* inst, cmRecdPlay* rcdply )
2511
 cmDspRC_t _cmDspRecdPlayParseRsrc( cmDspCtx_t* ctx, cmDspInst_t* inst, cmRecdPlay* rcdply )
2519
     path = "";
2523
     path = "";
2520
 
2524
 
2521
   cmJsonH_t     jsH = cmDspSysPgmRsrcHandle(ctx->dspH);
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
   if( jnp == NULL || cmJsonIsArray(jnp)==false )
2528
   if( jnp == NULL || cmJsonIsArray(jnp)==false )
2525
   {
2529
   {
2585
 
2589
 
2586
   cmDspRecdPlay_t* p = (cmDspRecdPlay_t*)inst;
2590
   cmDspRecdPlay_t* p = (cmDspRecdPlay_t*)inst;
2587
 
2591
 
2588
-  p->scLocIdx = 0;
2592
+  //p->scLocIdx = 0;
2589
 
2593
 
2590
 
2594
 
2591
   if((fn = cmDspStrcz(inst,kFnPrId)) == NULL || strlen(fn)==0 )
2595
   if((fn = cmDspStrcz(inst,kFnPrId)) == NULL || strlen(fn)==0 )
2614
     if((rc = _cmDspRecdPlayParseRsrc(ctx,inst,p->rcdply)) != kOkDspRC )
2618
     if((rc = _cmDspRecdPlayParseRsrc(ctx,inst,p->rcdply)) != kOkDspRC )
2615
       rc = cmDspInstErr(ctx,inst,kInstResetFailDspRC,"The 'recdplay' segment pre-load failed.");
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
   p->offSymId       = cmSymTblId(ctx->stH,"off");
2661
   p->offSymId       = cmSymTblId(ctx->stH,"off");
2658
   p->audioOutBaseId = audioOutBase;
2662
   p->audioOutBaseId = audioOutBase;
2659
   p->chCnt          = chCnt;
2663
   p->chCnt          = chCnt;
2660
-  p->scLocIdx       = 0;
2664
+  //p->scLocIdx       = 0;
2661
 
2665
 
2662
   printf("0 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
2666
   printf("0 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
2663
 
2667
 
2753
       {
2757
       {
2754
         printf("rewind\n");
2758
         printf("rewind\n");
2755
         cmRecdPlayRewind(p->rcdply);
2759
         cmRecdPlayRewind(p->rcdply);
2756
-        p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
2760
+        //p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
2757
       }
2761
       }
2758
       else
2762
       else
2759
         if( cmDspSymbol(inst,kCmdPrId) == p->offSymId )
2763
         if( cmDspSymbol(inst,kCmdPrId) == p->offSymId )
2777
         if( endScLocIdx < cmDspUInt(inst,kScInitLocIdxPrId) )
2781
         if( endScLocIdx < cmDspUInt(inst,kScInitLocIdxPrId) )
2778
           break;
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
       break;
2825
       break;
2821
   }
2826
   }

Loading…
Cancel
Save