|
@@ -27,7 +27,6 @@
|
27
|
27
|
#include "cmDspSys.h"
|
28
|
28
|
#include "cmMath.h"
|
29
|
29
|
|
30
|
|
-
|
31
|
30
|
#include "cmAudioFile.h"
|
32
|
31
|
#include "cmFileSys.h"
|
33
|
32
|
#include "cmProcObj.h"
|
|
@@ -2371,6 +2370,7 @@ cmDspClass_t _cmNanoMapDC;
|
2371
|
2370
|
typedef struct
|
2372
|
2371
|
{
|
2373
|
2372
|
cmDspInst_t inst;
|
|
2373
|
+
|
2374
|
2374
|
} cmDspNanoMap_t;
|
2375
|
2375
|
|
2376
|
2376
|
cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 )
|
|
@@ -2383,6 +2383,8 @@ cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, un
|
2383
|
2383
|
|
2384
|
2384
|
void _cmDspNanoMapPgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm )
|
2385
|
2385
|
{
|
|
2386
|
+ cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
|
|
2387
|
+
|
2386
|
2388
|
unsigned i;
|
2387
|
2389
|
|
2388
|
2390
|
for(i=0; i<kMidiChCnt; ++i)
|
|
@@ -2428,7 +2430,7 @@ cmDspRC_t _cmDspNanoMapReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
2428
|
2430
|
|
2429
|
2431
|
cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
|
2430
|
2432
|
{
|
2431
|
|
- //cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
|
|
2433
|
+ cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
|
2432
|
2434
|
|
2433
|
2435
|
switch( evt->dstVarId )
|
2434
|
2436
|
{
|
|
@@ -2439,7 +2441,7 @@ cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
2439
|
2441
|
|
2440
|
2442
|
case kStatusNmId:
|
2441
|
2443
|
{
|
2442
|
|
- unsigned status = cmDsvGetUInt(evt->valuePtr);
|
|
2444
|
+ unsigned status = cmDsvGetUInt(evt->valuePtr);
|
2443
|
2445
|
if( (status & 0xf0) == kNoteOnMdId )
|
2444
|
2446
|
{
|
2445
|
2447
|
unsigned d0 = cmDspUInt(inst,kD0NmId);
|
|
@@ -2447,6 +2449,7 @@ cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
2447
|
2449
|
status = (status & 0xf0) + ch;
|
2448
|
2450
|
cmDspSetUInt(ctx,inst,kStatusNmId,status);
|
2449
|
2451
|
}
|
|
2452
|
+
|
2450
|
2453
|
}
|
2451
|
2454
|
break;
|
2452
|
2455
|
|
|
@@ -2485,6 +2488,7 @@ enum
|
2485
|
2488
|
kMaxLaSecsPrId,
|
2486
|
2489
|
kCurLaSecsPrId,
|
2487
|
2490
|
kFadeRatePrId,
|
|
2491
|
+ kScInitLocIdxPrId,
|
2488
|
2492
|
kScLocIdxPrId,
|
2489
|
2493
|
kCmdPrId,
|
2490
|
2494
|
kInAudioBasePrId
|
|
@@ -2501,9 +2505,83 @@ 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
|
|
|
2511
|
+cmDspRC_t _cmDspRecdPlayParseRsrc( cmDspCtx_t* ctx, cmDspInst_t* inst, cmRecdPlay* rcdply )
|
|
2512
|
+{
|
|
2513
|
+ cmDspRC_t rc = kOkDspRC;
|
|
2514
|
+ const cmChar_t* path = NULL;
|
|
2515
|
+
|
|
2516
|
+ // read the 'recdplay' audio file path
|
|
2517
|
+ if( cmDspRsrcString( ctx->dspH, &path, "recdPlayPath", NULL ) != kOkDspRC )
|
|
2518
|
+ {
|
|
2519
|
+ cmDspInstErr(ctx,inst,kRsrcNotFoundDspRC,"The 'recdPlayPath' resource string was not found.");
|
|
2520
|
+ }
|
|
2521
|
+
|
|
2522
|
+ if( path == NULL )
|
|
2523
|
+ path = "";
|
|
2524
|
+
|
|
2525
|
+ cmJsonH_t jsH = cmDspSysPgmRsrcHandle(ctx->dspH);
|
|
2526
|
+ cmJsonNode_t* jnp = cmJsonFindValue(jsH,"recdPlay",NULL, kArrayTId);
|
|
2527
|
+
|
|
2528
|
+ if( jnp == NULL || cmJsonIsArray(jnp)==false )
|
|
2529
|
+ {
|
|
2530
|
+ // this is really a warning - the object does not require preloaded segments.
|
|
2531
|
+ cmDspInstErr(ctx,inst,kRsrcNotFoundDspRC,"The 'recdPlay' resource used to define pre-loaded segments was not found.");
|
|
2532
|
+ return kOkDspRC;
|
|
2533
|
+ }
|
|
2534
|
+
|
|
2535
|
+ unsigned n = cmJsonChildCount(jnp);
|
|
2536
|
+ unsigned i;
|
|
2537
|
+
|
|
2538
|
+ // for each 'recdplay' segment record
|
|
2539
|
+ for(i=0; i<n && rc==kOkDspRC; ++i)
|
|
2540
|
+ {
|
|
2541
|
+ cmJsonNode_t* cnp = cmJsonArrayElement(jnp,i);
|
|
2542
|
+ const cmChar_t* label = NULL;
|
|
2543
|
+ unsigned segSymId = cmInvalidId;
|
|
2544
|
+ const cmChar_t* errLabel = NULL;
|
|
2545
|
+ const cmChar_t* fn = NULL;
|
|
2546
|
+
|
|
2547
|
+ // read the ith segment record
|
|
2548
|
+ if( cmJsonMemberValues(cnp,&errLabel,
|
|
2549
|
+ "label", kStringTId, &label,
|
|
2550
|
+ "file", kStringTId, &fn,
|
|
2551
|
+ NULL) != kOkJsRC )
|
|
2552
|
+ {
|
|
2553
|
+ rc = cmDspInstErr(ctx,inst,kRsrcNotFoundDspRC,"The record at index %i in the 'recdPlay' pre-loaded segment list could not be parsed.",i);
|
|
2554
|
+ goto errLabel;
|
|
2555
|
+ }
|
|
2556
|
+
|
|
2557
|
+ // find or generate the symbol id for the segment label symbol
|
|
2558
|
+ if((segSymId = cmSymTblRegisterSymbol(ctx->stH,label)) == cmInvalidId )
|
|
2559
|
+ {
|
|
2560
|
+ rc = cmDspInstErr(ctx,inst,kSymNotFoundDspRC,"The 'recdPlay' pre-load segment symbol '%s' could not be found or registered.",cmStringNullGuard(label));
|
|
2561
|
+ goto errLabel;
|
|
2562
|
+ }
|
|
2563
|
+
|
|
2564
|
+ // create the full path name for the segment audio file
|
|
2565
|
+ if((fn = cmFsMakeFn( path, fn, NULL, NULL )) == NULL )
|
|
2566
|
+ {
|
|
2567
|
+ rc = cmDspInstErr(ctx,inst,kFileSysFailDspRC,"The 'recdPlay' file name '%s/%s' could not be generated.",cmStringNullGuard(path),cmStringNullGuard(fn));
|
|
2568
|
+ goto errLabel;
|
|
2569
|
+ }
|
|
2570
|
+
|
|
2571
|
+
|
|
2572
|
+ // pre-load the segment
|
|
2573
|
+ if( cmRecdPlayInsertRecord(rcdply,segSymId,fn) != cmOkRC )
|
|
2574
|
+ rc = cmDspInstErr(ctx,inst,kSubSysFailDspRC,"The 'recdPlay' segment label:'%s' file:'%s' could not be loaded.",cmStringNullGuard(label),cmStringNullGuard(fn));
|
|
2575
|
+
|
|
2576
|
+
|
|
2577
|
+ cmFsFreeFn(fn);
|
|
2578
|
+
|
|
2579
|
+ }
|
|
2580
|
+
|
|
2581
|
+ errLabel:
|
|
2582
|
+ return rc;
|
|
2583
|
+}
|
|
2584
|
+
|
2507
|
2585
|
cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
|
2508
|
2586
|
{
|
2509
|
2587
|
cmDspRC_t rc =kOkDspRC;
|
|
@@ -2511,14 +2589,14 @@ cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
|
2511
|
2589
|
|
2512
|
2590
|
cmDspRecdPlay_t* p = (cmDspRecdPlay_t*)inst;
|
2513
|
2591
|
|
2514
|
|
- p->scLocIdx = 0;
|
|
2592
|
+ //p->scLocIdx = 0;
|
2515
|
2593
|
|
2516
|
2594
|
|
2517
|
2595
|
if((fn = cmDspStrcz(inst,kFnPrId)) == NULL || strlen(fn)==0 )
|
2518
|
|
- return cmErrMsg(&inst->classPtr->err, kInvalidArgDspRC, "No score file name supplied.");
|
|
2596
|
+ return cmDspInstErr(ctx,inst, kInvalidArgDspRC, "No score file name supplied.");
|
2519
|
2597
|
|
2520
|
2598
|
if( cmScoreInitialize(ctx->cmCtx, &p->scH, fn, cmDspSampleRate(ctx), NULL, 0, NULL, NULL, ctx->stH ) != kOkScRC )
|
2521
|
|
- return cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Unable to open the score '%s'.",fn);
|
|
2599
|
+ return cmDspInstErr(ctx,inst, kSubSysFailDspRC, "Unable to open the score '%s'.",fn);
|
2522
|
2600
|
|
2523
|
2601
|
if( cmScoreIsValid(p->scH) )
|
2524
|
2602
|
{
|
|
@@ -2537,6 +2615,11 @@ cmDspRC_t _cmDspRecdPlayOpenScore( cmDspCtx_t* ctx, cmDspInst_t* inst )
|
2537
|
2615
|
for(i=0; i<markerCnt; ++i)
|
2538
|
2616
|
cmRecdPlayRegisterFrag(p->rcdply,i, cmScoreMarkerLabelSymbolId(p->scH,i ));
|
2539
|
2617
|
|
|
2618
|
+ if((rc = _cmDspRecdPlayParseRsrc(ctx,inst,p->rcdply)) != kOkDspRC )
|
|
2619
|
+ rc = cmDspInstErr(ctx,inst,kInstResetFailDspRC,"The 'recdplay' segment pre-load failed.");
|
|
2620
|
+
|
|
2621
|
+ //p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
|
|
2622
|
+
|
2540
|
2623
|
}
|
2541
|
2624
|
|
2542
|
2625
|
return rc;
|
|
@@ -2565,6 +2648,7 @@ cmDspInst_t* _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
|
2565
|
2648
|
1, "maxla", kMaxLaSecsPrId, 0,0, kInDsvFl | kDoubleDsvFl | kReqArgDsvFl, "Maximum look-ahead buffer in seconds.",
|
2566
|
2649
|
1, "curla", kCurLaSecsPrId, 0,0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Current look-head buffer in seconds.",
|
2567
|
2650
|
1, "frate", kFadeRatePrId, 0,0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Fade rate in dB per second.",
|
|
2651
|
+ 1, "initIdx",kScInitLocIdxPrId,0,0,kInDsvFl | kUIntDsvFl, "Score search start location.",
|
2568
|
2652
|
1, "index", kScLocIdxPrId, 0,0, kInDsvFl | kUIntDsvFl, "Score follower location index.",
|
2569
|
2653
|
1, "cmd", kCmdPrId, 0,0, kInDsvFl | kSymDsvFl, "on=reset off=stop.",
|
2570
|
2654
|
chCnt, "in", kInAudioBasePrId,0,1, kInDsvFl | kAudioBufDsvFl, "Audio input",
|
|
@@ -2577,7 +2661,7 @@ cmDspInst_t* _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
|
2577
|
2661
|
p->offSymId = cmSymTblId(ctx->stH,"off");
|
2578
|
2662
|
p->audioOutBaseId = audioOutBase;
|
2579
|
2663
|
p->chCnt = chCnt;
|
2580
|
|
- p->scLocIdx = 0;
|
|
2664
|
+ //p->scLocIdx = 0;
|
2581
|
2665
|
|
2582
|
2666
|
printf("0 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
|
2583
|
2667
|
|
|
@@ -2585,9 +2669,12 @@ cmDspInst_t* _cmDspRecdPlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
|
2585
|
2669
|
cmDspSetDefaultDouble(ctx,&p->inst, kMaxLaSecsPrId,0.0, 2.0);
|
2586
|
2670
|
cmDspSetDefaultDouble(ctx,&p->inst, kCurLaSecsPrId,0.0, 0.1);
|
2587
|
2671
|
cmDspSetDefaultDouble(ctx,&p->inst, kFadeRatePrId, 0.0, 1.0);
|
|
2672
|
+ cmDspSetDefaultUInt( ctx,&p->inst, kScInitLocIdxPrId,0,0);
|
2588
|
2673
|
|
2589
|
2674
|
printf("1 max la secs:%f\n",cmDspDouble(&p->inst,kMaxLaSecsPrId));
|
2590
|
2675
|
|
|
2676
|
+
|
|
2677
|
+
|
2591
|
2678
|
|
2592
|
2679
|
return &p->inst;
|
2593
|
2680
|
}
|
|
@@ -2670,7 +2757,7 @@ cmDspRC_t _cmDspRecdPlayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
2670
|
2757
|
{
|
2671
|
2758
|
printf("rewind\n");
|
2672
|
2759
|
cmRecdPlayRewind(p->rcdply);
|
2673
|
|
- p->scLocIdx = 0;
|
|
2760
|
+ //p->scLocIdx = cmDspUInt(inst,kScInitLocIdxPrId);
|
2674
|
2761
|
}
|
2675
|
2762
|
else
|
2676
|
2763
|
if( cmDspSymbol(inst,kCmdPrId) == p->offSymId )
|
|
@@ -2683,49 +2770,57 @@ cmDspRC_t _cmDspRecdPlayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
2683
|
2770
|
cmRecdPlaySetLaSecs(p->rcdply, cmDspDouble(inst,kCurLaSecsPrId));
|
2684
|
2771
|
break;
|
2685
|
2772
|
|
|
2773
|
+ case kScInitLocIdxPrId:
|
|
2774
|
+ printf("init-idx:%i\n",cmDspUInt(inst,kScInitLocIdxPrId));
|
|
2775
|
+ break;
|
|
2776
|
+
|
2686
|
2777
|
case kScLocIdxPrId:
|
2687
|
2778
|
{
|
2688
|
|
- unsigned endScLocIdx = cmDspUInt(inst,kScLocIdxPrId) ;
|
|
2779
|
+ unsigned endScLocIdx = cmDspUInt(inst,kScLocIdxPrId);
|
2689
|
2780
|
|
2690
|
|
- for(; p->scLocIdx<=endScLocIdx; p->scLocIdx+=1)
|
2691
|
|
- {
|
2692
|
|
- cmScoreLoc_t* loc = cmScoreLoc(p->scH, p->scLocIdx );
|
2693
|
|
- cmScoreMarker_t* mp = loc->markList;
|
|
2781
|
+ if( endScLocIdx < cmDspUInt(inst,kScInitLocIdxPrId) )
|
|
2782
|
+ break;
|
2694
|
2783
|
|
2695
|
|
- for(; mp!=NULL; mp=mp->link)
|
2696
|
|
- switch( mp->markTypeId )
|
2697
|
|
- {
|
2698
|
|
- case kRecdBegScMId:
|
2699
|
|
- printf("recd-beg\n");
|
2700
|
|
- cmRecdPlayBeginRecord(p->rcdply, mp->labelSymId );
|
2701
|
|
- break;
|
|
2784
|
+ cmScoreLoc_t* loc = cmScoreLoc(p->scH, endScLocIdx );
|
|
2785
|
+ if( loc == NULL )
|
|
2786
|
+ break;
|
|
2787
|
+
|
|
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;
|
2702
|
2797
|
|
2703
|
|
- case kRecdEndScMId:
|
2704
|
|
- printf("recd-end\n");
|
2705
|
|
- cmRecdPlayEndRecord(p->rcdply, mp->labelSymId );
|
2706
|
|
- break;
|
|
2798
|
+ case kRecdEndScMId:
|
|
2799
|
+ printf("recd-end %s\n",cmSymTblLabel(ctx->stH,mp->labelSymId));
|
|
2800
|
+ cmRecdPlayEndRecord(p->rcdply, mp->labelSymId );
|
|
2801
|
+ break;
|
2707
|
2802
|
|
2708
|
|
- case kPlayBegScMId:
|
2709
|
|
- printf("play-beg\n");
|
2710
|
|
- cmRecdPlayBeginPlay(p->rcdply, mp->labelSymId );
|
2711
|
|
- break;
|
|
2803
|
+ case kPlayBegScMId:
|
|
2804
|
+ printf("play-beg\n");
|
|
2805
|
+ cmRecdPlayBeginPlay(p->rcdply, mp->labelSymId );
|
|
2806
|
+ break;
|
2712
|
2807
|
|
2713
|
|
- case kPlayEndScMId:
|
2714
|
|
- printf("play-end\n");
|
2715
|
|
- cmRecdPlayEndPlay(p->rcdply, mp->labelSymId );
|
2716
|
|
- break;
|
|
2808
|
+ case kPlayEndScMId:
|
|
2809
|
+ printf("play-end\n");
|
|
2810
|
+ cmRecdPlayEndPlay(p->rcdply, mp->labelSymId );
|
|
2811
|
+ break;
|
2717
|
2812
|
|
2718
|
|
- case kFadeScMId:
|
2719
|
|
- printf("fade-beg\n");
|
2720
|
|
- cmRecdPlayBeginFade(p->rcdply, mp->labelSymId, cmDspDouble(inst,kFadeRatePrId) );
|
2721
|
|
- break;
|
|
2813
|
+ case kFadeScMId:
|
|
2814
|
+ printf("fade-beg\n");
|
|
2815
|
+ cmRecdPlayBeginFade(p->rcdply, mp->labelSymId, cmDspDouble(inst,kFadeRatePrId) );
|
|
2816
|
+ break;
|
2722
|
2817
|
|
2723
|
|
- default:
|
2724
|
|
- break;
|
2725
|
|
- }
|
2726
|
|
- }
|
|
2818
|
+ default:
|
|
2819
|
+ break;
|
|
2820
|
+ }
|
|
2821
|
+
|
2727
|
2822
|
|
2728
|
|
- p->scLocIdx = endScLocIdx+1;
|
|
2823
|
+ //p->scLocIdx = endScLocIdx+1;
|
2729
|
2824
|
}
|
2730
|
2825
|
break;
|
2731
|
2826
|
}
|