Переглянути джерело

cmProc.h/c: Added cmScModulator cmDspKr.h/c,cmDspPgmKr add cmScMod

master
kevin 11 роки тому
джерело
коміт
9b9e626287
6 змінених файлів з 720 додано та 25 видалено
  1. 407
    9
      cmProc4.c
  2. 73
    2
      cmProc4.h
  3. 1
    1
      dsp/cmDspBuiltIn.c
  4. 167
    2
      dsp/cmDspKr.c
  5. 1
    0
      dsp/cmDspKr.h
  6. 71
    11
      dsp/cmDspPgmKr.c

+ 407
- 9
cmProc4.c Переглянути файл

@@ -1442,6 +1442,7 @@ void _cmScMatchPathPop( cmScMatch* r )
1442 1442
   r->p_cur       = tp;
1443 1443
 }
1444 1444
 
1445
+
1445 1446
 double _cmScMatchCalcCandidateCost( cmScMatch* r )
1446 1447
 {
1447 1448
   cmScMatchPath_t* cp = r->p_cur;
@@ -1959,7 +1960,7 @@ cmRC_t cmScMatcherInit(  cmScMatcher* p, double srate, cmScH_t scH, unsigned scW
1959 1960
   p->cbFunc     = cbFunc;
1960 1961
   p->cbArg      = cbArg;
1961 1962
   p->mn         = midiWndN;
1962
-  p->midiBuf    = cmMemResize(cmScMatchMidi_t,p->midiBuf,p->mn);
1963
+  p->midiBuf    = cmMemResizeZ(cmScMatchMidi_t,p->midiBuf,p->mn);
1963 1964
   p->stepCnt    = 3;
1964 1965
   p->maxMissCnt = p->stepCnt+1;
1965 1966
   p->rn         = 2 * cmScoreEvtCount(scH);
@@ -2552,8 +2553,8 @@ cmRC_t    cmScMeasInit(  cmScMeas* p, cmScH_t scH, double srate, const unsigned*
2552 2553
   p->mn      = 2 * cmScoreEvtCount(scH);
2553 2554
   p->midiBuf = cmMemResizeZ(cmScMatchMidi_t,p->midiBuf,p->mn);
2554 2555
   p->sn      = cmScoreSetCount(scH);
2555
-  p->set     = cmMemResize(cmScMeasSet_t,p->set,p->sn);
2556
-  p->dynRef  = cmMemResize(unsigned,p->dynRef,dynRefCnt);
2556
+  p->set     = cmMemResizeZ(cmScMeasSet_t,p->set,p->sn);
2557
+  p->dynRef  = cmMemResizeZ(unsigned,p->dynRef,dynRefCnt);
2557 2558
   p->dn      = dynRefCnt;
2558 2559
   p->srate   = srate;
2559 2560
 
@@ -2753,7 +2754,7 @@ unsigned _cmScMeasTimeAlign( cmScMeas* p, cmScMeasSet_t* sp, cmScMatchMidi_t* m,
2753 2754
 
2754 2755
   assert(b[0].smpIdx != cmInvalidIdx && b[bn-1].smpIdx != cmInvalidIdx);
2755 2756
 
2756
-  // calc avg. smpIdx and insert missing values
2757
+  // calc avg. smpIdx, insert missing values, and convert b[].smpIdx to delta smp index
2757 2758
   for(i=0,j=0; i<bn; ++i)
2758 2759
   {
2759 2760
     if( b[i].cnt > 1 )
@@ -2820,7 +2821,7 @@ double _cmScMeasEven( cmScMeas* p, cmScMeasSet_t* sp, cmScMatchMidi_t* m, unsign
2820 2821
   // calc std-dev of delta time
2821 2822
   double d_sd  = 0;    
2822 2823
   for(i=0; i<bn-1; ++i)
2823
-    d_sd      += (b[i].val-d_avg) * (b[i].val-d_avg);
2824
+    d_sd  += (b[i].val-d_avg) * (b[i].val-d_avg);
2824 2825
   
2825 2826
   // if there is no deviation then we can't compute a z-score
2826 2827
   // (this will happen if we fill in all the missing values based on 2 values)
@@ -2832,7 +2833,7 @@ double _cmScMeasEven( cmScMeas* p, cmScMeasSet_t* sp, cmScMatchMidi_t* m, unsign
2832 2833
   // calc avg. z-score
2833 2834
   double z  = 0;
2834 2835
   for(i=0; i<bn-1; ++i)
2835
-    z      += fabs(b[i].val - d_avg)/d_sd;
2836
+    z  += fabs(b[i].val - d_avg)/d_sd;
2836 2837
 
2837 2838
   double val = z / (bn-1);
2838 2839
 
@@ -3063,6 +3064,7 @@ cmRC_t cmScMeasExec( cmScMeas* p, unsigned mni, unsigned locIdx, unsigned scEvtI
3063 3064
     return cmCtxRtCondition( &p->obj, cmEofRC, "The MIDI buffer is full."); 
3064 3065
 
3065 3066
   int n_mii = cmInvalidIdx;
3067
+
3066 3068
   // locate the MIDI event assoc'd with 'mni'  ...
3067 3069
   if( p->mii>0 && mni <= p->midiBuf[p->mii-1].mni )
3068 3070
   {
@@ -3115,6 +3117,7 @@ cmRC_t cmScMeasExec( cmScMeas* p, unsigned mni, unsigned locIdx, unsigned scEvtI
3115 3117
   }
3116 3118
 
3117 3119
   p->vsi = p->nsi;
3120
+  p->vsli = p->nsli;
3118 3121
 
3119 3122
   // for each cmScore location between p->nsli and scLocIdx 
3120 3123
   for(; p->nsli<=scLocIdx && p->nsi < p->sn; ++p->nsli)
@@ -3123,7 +3126,6 @@ cmRC_t cmScMeasExec( cmScMeas* p, unsigned mni, unsigned locIdx, unsigned scEvtI
3123 3126
     // ahead of the next sets ending location.
3124 3127
     while( cmMin(maxScLocIdx,p->set[p->nsi].esli+1) == p->nsli )
3125 3128
     {
3126
-
3127 3129
       // calculate the value assoc'd with p->set[p->nsi]
3128 3130
       _cmScMeasCalcVal(p, p->set + p->nsi, n_mii );
3129 3131
 
@@ -3158,10 +3160,10 @@ cmRC_t cmScAlignScanToTimeLineEvent( cmScMatcher* p, cmTlH_t tlH, cmTlObj_t* top
3158 3160
 
3159 3161
       switch( rc )
3160 3162
       {
3161
-        case cmOkRC:        // continue processing MIDI events
3163
+        case cmOkRC:         // continue processing MIDI events
3162 3164
           break;
3163 3165
 
3164
-        case cmEofRC:       // end of the score was encountered
3166
+        case cmEofRC:        // end of the score was encountered
3165 3167
           break;
3166 3168
 
3167 3169
         case cmInvalidArgRC: // p->eli was not set correctly
@@ -3323,3 +3325,399 @@ void       cmScAlignScanMarkers(  cmRpt_t* rpt, cmTlH_t tlH, cmScH_t scH )
3323 3325
   cmScMeasFree(&mp);
3324 3326
   cmCtxFree(&ctx);
3325 3327
 }
3328
+
3329
+//=======================================================================================================================
3330
+cmScModulator* cmScModulatorAlloc( cmCtx* c, cmScModulator* p, cmCtx_t* ctx, cmSymTblH_t stH, double srate, unsigned samplesPerCycle, const cmChar_t* fn, const cmChar_t* modLabel, cmScModCb_t cbFunc, void* cbArg )
3331
+{
3332
+  cmScModulator* op = cmObjAlloc(cmScModulator,c,p);
3333
+
3334
+  if( ctx != NULL )
3335
+    if( cmScModulatorInit(op,ctx,stH,srate,samplesPerCycle,fn,modLabel,cbFunc,cbArg) != cmOkRC )
3336
+      cmScModulatorFree(&op);
3337
+
3338
+  return op;
3339
+}
3340
+
3341
+cmRC_t cmScModulatorFree(  cmScModulator** pp )
3342
+{
3343
+  cmRC_t rc = cmOkRC;
3344
+  if( pp==NULL || *pp==NULL )
3345
+    return rc;
3346
+
3347
+  cmScModulator* p = *pp;
3348
+  if((rc = cmScModulatorFinal(p)) != cmOkRC )
3349
+    return rc;
3350
+
3351
+  cmMemFree(p->earray);
3352
+  cmObjFree(pp);
3353
+  return rc;
3354
+}
3355
+
3356
+typedef struct
3357
+{
3358
+  unsigned        typeId;
3359
+  unsigned        minArgCnt;
3360
+  const cmChar_t* label;
3361
+} _cmScModTypeMap_t;
3362
+
3363
+_cmScModTypeMap_t _cmScModTypeArray[] =
3364
+{
3365
+  { kSetModTId,     1, "set" },
3366
+  { kLineModTId,    2, "line" },
3367
+  { kSetLineModTId, 3, "sline" },
3368
+  { kInvalidModTId, 0, "<invalid>"}
3369
+};
3370
+
3371
+const _cmScModTypeMap_t*  _cmScModTypeLabelToMap( const cmChar_t* label )
3372
+{
3373
+  unsigned i;
3374
+  for(i=0; _cmScModTypeArray[i].typeId!=kInvalidModTId; ++i)
3375
+    if( strcmp(_cmScModTypeArray[i].label,label) == 0 )
3376
+      return _cmScModTypeArray + i;
3377
+
3378
+  return NULL;
3379
+}
3380
+
3381
+cmScModVar_t* _cmScModulatorInsertValue( cmScModulator* p, unsigned varSymId )
3382
+{
3383
+  cmScModVar_t* vp = p->vlist;  
3384
+  for(; vp!=NULL; vp=vp->vlink)
3385
+    if( varSymId == vp->varSymId )
3386
+      return vp;
3387
+
3388
+  vp = cmMemAllocZ(cmScModVar_t,1);
3389
+  vp->varSymId = varSymId;
3390
+  vp->vlink    = p->vlist;
3391
+  p->vlist     = vp;
3392
+  return vp;
3393
+}
3394
+
3395
+cmRC_t _cmScModulatorInsertEntry(cmScModulator* p, unsigned idx, unsigned scLocIdx, unsigned modSymId, unsigned varSymId, unsigned typeId, const double* av, unsigned an)
3396
+{
3397
+  assert( idx < p->en );
3398
+
3399
+  if( p->modSymId != modSymId )
3400
+    return cmOkRC;
3401
+
3402
+  p->earray[idx].scLocIdx = scLocIdx;
3403
+  p->earray[idx].typeId   = typeId;
3404
+  p->earray[idx].parray   = an==0 ? NULL : cmMemAllocZ(double,an);
3405
+  p->earray[idx].pn       = an;
3406
+  p->earray[idx].valPtr   = _cmScModulatorInsertValue(p,varSymId);
3407
+
3408
+  unsigned i;
3409
+  for(i=0; i<an; ++i)
3410
+    p->earray[idx].parray[i] = av[i];
3411
+
3412
+  return cmOkRC;
3413
+}
3414
+
3415
+
3416
+/*
3417
+{
3418
+  [
3419
+  { loc:123, mod:modlabel, var:varlabel, param:[ ] }
3420
+  ]
3421
+}
3422
+ */
3423
+
3424
+  cmRC_t _cmScModulatorParse( cmScModulator* p, cmCtx_t* ctx, cmSymTblH_t stH, const cmChar_t* fn )
3425
+{
3426
+  cmRC_t        rc  = cmOkRC;
3427
+  cmJsonNode_t* jnp = NULL;
3428
+  cmJsonH_t     jsH = cmJsonNullHandle;
3429
+  unsigned      i;
3430
+
3431
+  // read the JSON file
3432
+  if( cmJsonInitializeFromFile(&jsH, fn, ctx ) != kOkJsRC )
3433
+    return cmCtxRtCondition( &p->obj, cmInvalidArgRC, "JSON file parse failed on the modulator file: %s.",cmStringNullGuard(fn) );
3434
+
3435
+  jnp = cmJsonRoot(jsH);
3436
+
3437
+  // validate that the first child as an array
3438
+  if( jnp==NULL || ((jnp = cmJsonNodeMemberValue(jnp,"array")) == NULL) || cmJsonIsArray(jnp)==false )
3439
+  {
3440
+    rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Modulator file header syntax error in file:%s",cmStringNullGuard(fn) );
3441
+    goto errLabel;
3442
+  }
3443
+
3444
+  // allocate the entry array
3445
+  p->en     = cmJsonChildCount(jnp);
3446
+  p->earray = cmMemResizeZ(cmScModEntry_t,p->earray,p->en);
3447
+
3448
+  for(i=0; i<p->en; ++i)
3449
+  {
3450
+    cmJsRC_t        jsRC;
3451
+    const char*              errLabelPtr = NULL;
3452
+    unsigned                 scLocIdx    = cmInvalidIdx;
3453
+    const cmChar_t*          modLabel    = NULL;
3454
+    const cmChar_t*          varLabel    = NULL;
3455
+    const cmChar_t*          typeLabel   = NULL;
3456
+    cmJsonNode_t*            onp         = cmJsonArrayElement(jnp,i);
3457
+    cmJsonNode_t*            dnp         = NULL;
3458
+    const _cmScModTypeMap_t* map         = NULL;
3459
+
3460
+    if((jsRC = cmJsonMemberValues( onp, &errLabelPtr, 
3461
+          "loc", kIntTId,    &scLocIdx,
3462
+          "mod", kStringTId, &modLabel,
3463
+          "var", kStringTId, &varLabel,
3464
+          "type",kStringTId, &typeLabel,
3465
+          NULL )) != kOkJsRC )
3466
+    {
3467
+      if( errLabelPtr == NULL )
3468
+        rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Error:%s on record at index %i in file:%s",errLabelPtr,i,cmStringNullGuard(fn) );
3469
+      else
3470
+        rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Synax error in Modulator record at index %i in file:%s",i,cmStringNullGuard(fn) );
3471
+      goto errLabel;
3472
+    }
3473
+
3474
+    // validate the entry type label
3475
+    if((map = _cmScModTypeLabelToMap(typeLabel)) == NULL )
3476
+    {
3477
+      rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Unknown entry type '%s' in Modulator record at index %i in file:%s",cmStringNullGuard(typeLabel),i,cmStringNullGuard(fn) );
3478
+      goto errLabel;
3479
+    }
3480
+    
3481
+    // get a data pointer to the data node
3482
+    if((dnp = cmJsonNodeMemberValue(onp,"data")) == NULL )
3483
+    {
3484
+      rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Synax error in Modulator 'data' record at index %i in file:%s",i,cmStringNullGuard(fn) );
3485
+      goto errLabel;
3486
+    }
3487
+
3488
+    unsigned modSymId = cmSymTblRegisterSymbol(stH,modLabel);
3489
+    unsigned varSymId = cmSymTblRegisterSymbol(stH,varLabel);
3490
+
3491
+    // the data may be an array of doubles ....
3492
+    if( cmJsonIsArray(dnp) )
3493
+    {
3494
+      unsigned an = cmJsonChildCount(dnp);
3495
+      double   av[an];
3496
+      unsigned j;
3497
+
3498
+      // read each element in the data array
3499
+      for(j=0; j<an; ++j)
3500
+        if( cmJsonRealValue(cmJsonArrayElement(dnp,j), av+j ) != kOkJsRC )
3501
+        {
3502
+          rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Error parsing in Modulator 'data' record at index %i value index %i in file:%s",i,j,cmStringNullGuard(fn) );    
3503
+          goto errLabel;
3504
+        }
3505
+
3506
+      _cmScModulatorInsertEntry(p,i,scLocIdx,modSymId,varSymId,map->typeId,av,an);
3507
+    }
3508
+    else  // ... or a scalar
3509
+    {
3510
+      double v;
3511
+      if( cmJsonRealValue(dnp,&v) !=  kOkJsRC )
3512
+      {
3513
+        rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Error paring in Modulator 'data' on record index %i.",i,cmStringNullGuard(fn));
3514
+        goto errLabel;
3515
+      }
3516
+
3517
+      _cmScModulatorInsertEntry(p,i,scLocIdx,modSymId,varSymId,map->typeId,&v,1);
3518
+
3519
+    }
3520
+  }
3521
+
3522
+ errLabel:
3523
+
3524
+  // release the JSON tree
3525
+  if( cmJsonIsValid(jsH) )
3526
+    cmJsonFinalize(&jsH);
3527
+
3528
+  return rc;
3529
+}
3530
+
3531
+cmRC_t cmScModulatorInit(  cmScModulator* p, cmCtx_t* ctx, cmSymTblH_t stH, double srate, unsigned samplesPerCycle, const cmChar_t* fn, const cmChar_t* modLabel, cmScModCb_t cbFunc, void* cbArg )
3532
+{
3533
+  cmRC_t rc;
3534
+
3535
+  if((rc = cmScModulatorFinal(p)) != cmOkRC )
3536
+    return rc;
3537
+
3538
+  p->modSymId        = cmSymTblRegisterSymbol(stH,modLabel);
3539
+  p->cbFunc          = cbFunc;
3540
+  p->cbArg           = cbArg;
3541
+  p->samplesPerCycle = samplesPerCycle;
3542
+  p->srate           = srate;
3543
+
3544
+  if((rc = _cmScModulatorParse(p,ctx,stH,fn)) != cmOkRC )
3545
+    goto errLabel;
3546
+
3547
+ errLabel:
3548
+  if( rc != cmOkRC )
3549
+    cmScModulatorFinal(p);
3550
+  else
3551
+    cmScModulatorReset(p,0);
3552
+
3553
+  return rc;
3554
+}
3555
+
3556
+cmRC_t cmScModulatorFinal( cmScModulator* p )
3557
+{
3558
+  unsigned i;
3559
+
3560
+  // release each value record
3561
+  cmScModVar_t* vp = p->vlist;
3562
+  while( vp!=NULL )
3563
+  {
3564
+    cmScModVar_t* np = vp->vlink;
3565
+    cmMemFree(vp);
3566
+    vp=np;
3567
+  }
3568
+
3569
+  // release each entry record
3570
+  for(i=0; i<p->en; ++i)
3571
+    cmMemFree(p->earray[i].parray);
3572
+
3573
+  return cmOkRC;
3574
+}
3575
+
3576
+unsigned        cmScModulatorVarCount( cmScModulator* p )
3577
+{
3578
+  unsigned n = 0;
3579
+  const cmScModVar_t* vp = p->vlist;
3580
+  for(; vp!=NULL; vp=vp->vlink)
3581
+    ++n;
3582
+
3583
+  return n;
3584
+}
3585
+
3586
+cmScModVar_t* cmScModulatorVar( cmScModulator* p, unsigned idx )
3587
+{
3588
+  unsigned n = 0;
3589
+  cmScModVar_t* vp = p->vlist;
3590
+  for(; vp!=NULL; vp=vp->vlink,++n)
3591
+    if( n == idx )
3592
+      return vp;
3593
+
3594
+  assert(0);
3595
+  return NULL;
3596
+}
3597
+
3598
+cmRC_t cmScModulatorReset( cmScModulator* p, unsigned scLocIdx )
3599
+{
3600
+  p->alist = NULL;
3601
+  p->nei   = 0;
3602
+
3603
+  return cmScModulatorExec(p,scLocIdx);
3604
+}
3605
+
3606
+void  _cmScModUnlink( cmScModulator* p, cmScModVar_t* vp, cmScModVar_t* pp )
3607
+{
3608
+  if( pp == NULL )
3609
+    p->alist = vp->alink;
3610
+  else
3611
+    pp->alink = vp->alink;  
3612
+
3613
+  vp->flags = 0;
3614
+  vp->alink = NULL;  
3615
+  vp->entry = NULL;
3616
+}
3617
+
3618
+// Type specific variable activation
3619
+cmRC_t _cmScModActivate(cmScModulator* p, cmScModEntry_t* ep )
3620
+{
3621
+  cmRC_t rc = cmOkRC;
3622
+
3623
+  cmScModVar_t* vp = ep->valPtr;
3624
+
3625
+  switch( ep->typeId )
3626
+  {
3627
+    case kSetModTId:
3628
+      break;
3629
+
3630
+    case kLineModTId:
3631
+      vp->v0    = vp->value;
3632
+      vp->phase = 0;
3633
+      break;
3634
+
3635
+    case kSetLineModTId:
3636
+      vp->value     = ep->parray[0];
3637
+      vp->v0        = ep->parray[0];
3638
+      vp->phase     = 0;
3639
+      ep->parray[0] = ep->parray[1];
3640
+      ep->parray[1] = ep->parray[2];
3641
+      break;
3642
+
3643
+    default:
3644
+      { assert(0); }
3645
+  }
3646
+
3647
+  return rc;
3648
+}
3649
+
3650
+// Return true if vp should be deactivated otherwise return false.
3651
+bool  _cmScModExec( cmScModulator* p, cmScModVar_t* vp )
3652
+{
3653
+  bool fl = false;
3654
+  switch( vp->entry->typeId )
3655
+  {
3656
+    case kSetModTId:
3657
+      p->cbFunc(p->cbArg,vp->varSymId,vp->entry->parray[0]);
3658
+      fl = true;
3659
+      break;
3660
+
3661
+    case kSetLineModTId:
3662
+    case kLineModTId:
3663
+      {
3664
+        double v1 = vp->entry->parray[0];
3665
+        double v  = vp->value + (v1-vp->v0) * (vp->phase * p->samplesPerCycle) / (p->srate * vp->entry->parray[1]);        
3666
+
3667
+        if((fl =  (vp->value <= v1 && v >= v1) || (vp->value >= v1 && v <= v1 )) == true )
3668
+          v  = v1;
3669
+       
3670
+        vp->phase += 1;
3671
+        vp->value  = v;
3672
+        p->cbFunc(p->cbArg,vp->varSymId,v);
3673
+      }
3674
+      break;
3675
+
3676
+    default:
3677
+      { assert(0); }
3678
+  }
3679
+  return fl;
3680
+}
3681
+
3682
+
3683
+cmRC_t cmScModulatorExec( cmScModulator* p, unsigned scLocIdx )
3684
+{
3685
+  cmRC_t trc;
3686
+  cmRC_t rc = cmOkRC;
3687
+
3688
+  // trigger entries that have expired since the last call to this function
3689
+  for(; p->nei<p->en && p->earray[p->nei].scLocIdx<=scLocIdx; ++p->nei)
3690
+  {
3691
+    cmScModEntry_t* ep = p->earray + p->nei;
3692
+
3693
+    // if the variable assoc'd with this entry is not on the active list ...
3694
+    if( cmIsFlag(ep->valPtr->flags,kActiveModFl) == false )
3695
+    {
3696
+      // ... then push it onto the front of the active list ...
3697
+      ep->valPtr->flags = kActiveModFl; 
3698
+      ep->valPtr->alink = p->alist;
3699
+      p->alist          = ep->valPtr;
3700
+    }
3701
+
3702
+
3703
+    // do type specific activation
3704
+    if((trc = _cmScModActivate(p,ep)) != cmOkRC )
3705
+      rc = trc;
3706
+
3707
+    ep->valPtr->entry = ep;
3708
+
3709
+  }
3710
+    
3711
+  
3712
+  cmScModVar_t* pp = NULL;
3713
+  cmScModVar_t* vp = p->alist;
3714
+  for(; vp!=NULL; vp=vp->alink)
3715
+  {
3716
+    if( _cmScModExec(p,vp) )
3717
+      _cmScModUnlink(p,vp,pp);
3718
+    else
3719
+      pp = vp;
3720
+  }
3721
+
3722
+  return rc;
3723
+}

+ 73
- 2
cmProc4.h Переглянути файл

@@ -436,7 +436,7 @@ typedef struct
436 436
   unsigned         nsli;     // next score location index
437 437
 
438 438
   unsigned         vsi;      // set[vsi:nsi-1] indicates sets with new values following a call to cmScMeasExec()
439
-  
439
+  unsigned         vsli;     // vsli:nsli-1 indicates cmScore loc's to check for section triggers following a call to cmScMeasExec()
440 440
 } cmScMeas;
441 441
 
442 442
 //
@@ -448,7 +448,9 @@ typedef struct
448 448
 // 2) dynRef][ is the gives the MIDI velocity range for each dynamics
449 449
 // category: pppp-fff
450 450
 // 
451
-
451
+// 3) See a cmDspKr.c _cmScFolMatcherCb() for an example of how 
452
+// cmScMeas.vsi and cmScMeas.vsli are used to act on the results of
453
+// a call to cmMeasExec().
452 454
 
453 455
 cmScMeas* cmScMeasAlloc( cmCtx* c, cmScMeas* p, cmScH_t scH, double srate, const unsigned* dynRefArray, unsigned dynRefCnt );
454 456
 cmRC_t    cmScMeasFree(  cmScMeas** pp );
@@ -475,6 +477,75 @@ unsigned   cmScAlignScanToTimeLineEvent( cmScMatcher* p, cmTlH_t tlH, cmTlObj_t*
475 477
 // notes in each marker region and the score. 
476 478
 void       cmScAlignScanMarkers(  cmRpt_t* rpt, cmTlH_t tlH, cmScH_t scH );
477 479
 
480
+//=======================================================================================================================
481
+enum
482
+{
483
+  kInvalidModTId,
484
+  kSetModTId,      // set variable to parray[0] at scLocIdx
485
+  kLineModTId,     // linear ramp variable to parray[0] over parray[1] seconds
486
+  kSetLineModTId,  // set variable to parray[0] and ramp to parray[1] over parray[2] seconds
487
+};
488
+
489
+enum
490
+{
491
+  kActiveModFl = 0x01
492
+};
493
+
494
+struct cmScModEntry_str;
495
+
496
+typedef struct cmScModVar_str
497
+{
498
+  unsigned                 flags;    // see kXXXModFl flags above.
499
+  unsigned                 varSymId; // variable name 
500
+  double                   value;    // current value 
501
+  double                   v0;       // reserved internal variable
502
+  unsigned                 phase;    // cycle phase since activation
503
+  struct cmScModEntry_str* entry;    // last entry assoc'd with this value
504
+  struct cmScModVar_str*   vlink;    // p->vlist link
505
+  struct cmScModVar_str*   alink;    // p->alist link
506
+} cmScModVar_t;
507
+
508
+typedef struct cmScModEntry_str
509
+{
510
+  unsigned        scLocIdx;     // entry start time
511
+  unsigned        typeId;       // variable type
512
+  double*         parray;       // parray[pn] - parameter array
513
+  unsigned        pn;           // parameter count
514
+  cmScModVar_t*   valPtr;       // target variable 
515
+} cmScModEntry_t;
516
+
517
+typedef void (*cmScModCb_t)( void* cbArg, unsigned varSymId, double value );
518
+
519
+typedef struct
520
+{
521
+  cmObj           obj;
522
+  unsigned        modSymId;     // modulator name
523
+  cmScModCb_t     cbFunc;       // active value callback function
524
+  void*           cbArg;        // first arg to cbFunc()
525
+  unsigned        samplesPerCycle; // interval in samples between calls to cmScModulatorExec()
526
+  double          srate;        // system sample rate
527
+  cmScModEntry_t* earray;       // earray[en] - entry array sorted on ascending cmScModEntry_t.scLocIdx
528
+  unsigned        en;           // count 
529
+  cmScModVar_t*   vlist;        // variable list
530
+  cmScModVar_t*   alist;        // active variable list
531
+  unsigned        nei;          // next entry index
532
+} cmScModulator;
533
+
534
+
535
+cmScModulator* cmScModulatorAlloc( cmCtx* c, cmScModulator* p, cmCtx_t* ctx, cmSymTblH_t stH, double srate, unsigned samplesPerCycle, const cmChar_t* fn, const cmChar_t* modLabel, cmScModCb_t cbFunc, void* cbArg );
536
+cmRC_t         cmScModulatorFree(  cmScModulator** pp );
537
+cmRC_t         cmScModulatorInit(  cmScModulator* p, cmCtx_t* ctx, cmSymTblH_t stH, double srate, unsigned samplesPerCycle, const cmChar_t* fn, const cmChar_t* modLabel, cmScModCb_t cbFunc, void* cbArg );
538
+cmRC_t         cmScModulatorFinal( cmScModulator* p );
539
+
540
+// Return count of variables.
541
+unsigned        cmScModulatorVarCount( cmScModulator* p );
542
+
543
+// Return a pointer to the variable at vlist[idx].
544
+cmScModVar_t* cmScModulatorVar( cmScModulator* p, unsigned idx ); 
545
+
546
+cmRC_t         cmScModulatorReset( cmScModulator* p, unsigned scLocIdx );
547
+cmRC_t         cmScModulatorExec(  cmScModulator* p, unsigned scLocIdx );
548
+
478 549
 #ifdef __cplusplus
479 550
 }
480 551
 #endif

+ 1
- 1
dsp/cmDspBuiltIn.c Переглянути файл

@@ -5019,7 +5019,7 @@ cmDspClassConsFunc_t _cmDspClassBuiltInArray[] =
5019 5019
   cmScoreClassCons,
5020 5020
   cmMidiFilePlayClassCons,
5021 5021
   cmScFolClassCons,
5022
-
5022
+  cmScModClassCons,
5023 5023
   NULL,
5024 5024
 };
5025 5025
 

+ 167
- 2
dsp/cmDspKr.c Переглянути файл

@@ -11,6 +11,7 @@
11 11
 #include "cmFile.h"
12 12
 #include "cmSymTbl.h"
13 13
 #include "cmJson.h"
14
+#include "cmText.h"
14 15
 #include "cmPrefs.h"
15 16
 #include "cmDspValue.h"
16 17
 #include "cmMsgProtocol.h"
@@ -154,6 +155,10 @@ cmDspRC_t _cmDspKrExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt
154 155
   unsigned          iChIdx  = 0;
155 156
   const cmSample_t* ip      = cmDspAudioBuf(ctx,inst,kAudioInKrId,iChIdx);
156 157
   unsigned          iSmpCnt = cmDspVarRows(inst,kAudioInKrId);
158
+
159
+  // if no connected
160
+  if( iSmpCnt == 0 )
161
+    return rc;
157 162
   
158 163
   unsigned          oChIdx  = 0;
159 164
   cmSample_t*       op      = cmDspAudioBuf(ctx,inst,kAudioOutKrId,oChIdx);
@@ -896,16 +901,20 @@ cmDspRC_t _cmDspScFolFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
896 901
   return kOkDspRC;
897 902
 }
898 903
 
904
+// This is a callback function from cmScMatcherExec() which is called when
905
+// this cmDspFol object receives a new score location index.
899 906
 void _cmScFolMatcherCb( cmScMatcher* p, void* arg, cmScMatcherResult_t* rp )
900 907
 {
901 908
   cmDspScFolCbArg_t* ap = (cmDspScFolCbArg_t*)arg;
902 909
 
910
+  
903 911
   if( cmScMeasExec(ap->sfp->smp, rp->mni, rp->locIdx, rp->scEvtIdx, rp->flags, rp->smpIdx, rp->pitch, rp->vel ) == cmOkRC )
904 912
   {
905
-    cmDspInst_t*  inst = (cmDspInst_t*)ap->sfp;
913
+    cmDspInst_t*  inst = &(ap->sfp->inst);
906 914
 
915
+    // send 'set' values that were calculated on the previous call to cmScMeasExec()
907 916
     unsigned i;
908
-    for(i=ap->sfp->smp->vsi; i<ap->sfp->smp->nsi; i++)
917
+    for(i=ap->sfp->smp->vsi; i<ap->sfp->smp->nsi; ++i)
909 918
     {
910 919
       switch( ap->sfp->smp->set[i].sp->varId )
911 920
       {
@@ -925,6 +934,16 @@ void _cmScFolMatcherCb( cmScMatcher* p, void* arg, cmScMatcherResult_t* rp )
925 934
           { assert(0); }
926 935
       }           
927 936
     }
937
+
938
+    /*
939
+    // trigger 'section' starts 
940
+    for(i=ap->sfp->smp->vsli; i<ap->sfp->smp->nsli; ++i)
941
+    {
942
+      const cmScoreLoc_t* locPtr = cmScoreLoc(ap->sfp->smp->mp->scH,i);
943
+      if( locPtr->begSectPtr != NULL )
944
+        cmDspSetUInt(ap->ctx,inst,kSectIndexSfId,locPtr->begSectPtr->index);
945
+    }
946
+    */
928 947
   }
929 948
 }
930 949
 
@@ -1047,3 +1066,149 @@ struct cmDspClass_str* cmScFolClassCons( cmDspCtx_t* ctx )
1047 1066
   return &_cmScFolDC;
1048 1067
 }
1049 1068
 
1069
+//==========================================================================================================================================
1070
+
1071
+enum
1072
+{
1073
+  kScLocIdxMdId
1074
+};
1075
+
1076
+cmDspClass_t _cmModulatorDC;
1077
+
1078
+typedef struct
1079
+{
1080
+  cmDspInst_t    inst;
1081
+  cmScModulator* mp;
1082
+  cmDspCtx_t*    tmp_ctx;       // used to temporarily hold the current cmDspCtx during callback
1083
+} cmDspScMod_t;
1084
+
1085
+void _cmDspScModCb( void* arg, unsigned varSymId, double value )
1086
+{
1087
+  cmDspScMod_t* p = (cmDspScMod_t*)arg;
1088
+
1089
+  cmDspVar_t* varPtr;
1090
+  if((varPtr = cmDspVarSymbolToPtr( p->tmp_ctx, &p->inst, varSymId, 0 )) == NULL )
1091
+    return;
1092
+
1093
+  cmDspSetDouble(p->tmp_ctx,&p->inst,varPtr->constId,value);
1094
+  
1095
+}
1096
+
1097
+cmDspInst_t*  _cmDspScModAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
1098
+{
1099
+  va_list vl1;
1100
+  va_copy(vl1,vl);
1101
+
1102
+  cmDspVarArg_t args[] =
1103
+  {
1104
+    { "index",   kScLocIdxMdId,0,0, kInDsvFl  | kUIntDsvFl,                "Score follower index input."},
1105
+    { NULL, 0, 0, 0, 0 }
1106
+  };
1107
+
1108
+  // validate the argument count
1109
+  if( va_cnt != 2 )
1110
+  {
1111
+    cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The Modulator requires at least two arguments.");
1112
+    return NULL;
1113
+  }    
1114
+
1115
+  // read the modulator file and label strings
1116
+  const cmChar_t* fn       = va_arg(vl1,const cmChar_t*);
1117
+  const cmChar_t* modLabel = va_arg(vl1,const cmChar_t*);
1118
+
1119
+  // validate the file
1120
+  if( fn==NULL || cmFsIsFile(fn)==false )
1121
+  {
1122
+    cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The Modulator file '%s' is not valid.",cmStringNullGuard(fn));
1123
+    return NULL;
1124
+  }
1125
+
1126
+  // allocate the internal modulator object
1127
+  cmScModulator* mp = cmScModulatorAlloc(ctx->cmProcCtx, NULL, ctx->cmCtx, ctx->stH, cmDspSampleRate(ctx), cmDspSamplesPerCycle(ctx), fn, modLabel, _cmDspScModCb, NULL );
1128
+  
1129
+  if(mp == NULL )
1130
+  {
1131
+    cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The internal modulator object initialization failed.");
1132
+    return NULL;
1133
+  }
1134
+  unsigned      fixArgCnt = 1;
1135
+  unsigned      argCnt    = fixArgCnt + cmScModulatorVarCount(mp);
1136
+  cmDspVarArg_t a[ argCnt+1 ];
1137
+  unsigned      i;
1138
+
1139
+  cmDspArgCopy( a, argCnt, 0, args, fixArgCnt );
1140
+
1141
+  for(i=fixArgCnt; i<argCnt; ++i)
1142
+  {
1143
+    unsigned            varIdx    = i - fixArgCnt;
1144
+    const cmScModVar_t* vp        = cmScModulatorVar(mp,varIdx);
1145
+    const cmChar_t*     label     = cmSymTblLabel( ctx->stH, vp->varSymId );
1146
+    const cmChar_t*     docStr    = cmTsPrintfS("Variable output for %s",label);
1147
+
1148
+    cmDspArgSetup(ctx, a + i, label, cmInvalidId, i, 0, 0, kOutDsvFl | kDoubleDsvFl, docStr ); 
1149
+  }
1150
+  cmDspArgSetupNull(a+argCnt); // set terminating arg. flags
1151
+
1152
+  cmDspScMod_t* p = cmDspInstAlloc(cmDspScMod_t,ctx,classPtr,a,instSymId,id,storeSymId,0,vl);
1153
+
1154
+  p->mp = mp;
1155
+  mp->cbArg = p;  // set the modulator callback arg
1156
+
1157
+  cmDspSetDefaultUInt(ctx,&p->inst,kScLocIdxMdId,0,0);
1158
+
1159
+  return &p->inst;
1160
+}
1161
+
1162
+cmDspRC_t _cmDspScModFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
1163
+{
1164
+  cmDspRC_t        rc = kOkDspRC;
1165
+  cmDspScMod_t* p = (cmDspScMod_t*)inst;
1166
+
1167
+  if( cmScModulatorFree(&p->mp) != kOkTlRC )
1168
+    return cmErrMsg(&inst->classPtr->err, kInstFinalFailDspRC, "Modulator release failed.");
1169
+
1170
+  return rc;
1171
+}
1172
+
1173
+
1174
+cmDspRC_t _cmDspScModReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
1175
+{
1176
+  cmDspRC_t       rc          = kOkDspRC;
1177
+
1178
+  cmDspApplyAllDefaults(ctx,inst);
1179
+
1180
+  return rc;
1181
+}
1182
+
1183
+cmDspRC_t _cmDspScModRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
1184
+{
1185
+
1186
+  cmDspSetEvent(ctx,inst,evt);
1187
+
1188
+  return kOkDspRC;
1189
+}
1190
+
1191
+cmDspRC_t _cmDspScModExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
1192
+{
1193
+  cmDspRC_t         rc = kOkDspRC;
1194
+  cmDspScMod_t* p  = (cmDspScMod_t*)inst;
1195
+  
1196
+  p->tmp_ctx = ctx;
1197
+  cmScModulatorExec(p->mp,cmDspUInt(inst,kScLocIdxMdId));
1198
+  return rc;
1199
+}
1200
+
1201
+struct cmDspClass_str* cmScModClassCons( cmDspCtx_t* ctx )
1202
+{
1203
+  cmDspClassSetup(&_cmModulatorDC,ctx,"ScMod",
1204
+    NULL,
1205
+    _cmDspScModAlloc,
1206
+    _cmDspScModFree,
1207
+    _cmDspScModReset,
1208
+    _cmDspScModExec,
1209
+    _cmDspScModRecv,
1210
+    NULL,NULL,
1211
+    "Score Driven Variable Modulator.");
1212
+
1213
+  return &_cmModulatorDC;
1214
+}

+ 1
- 0
dsp/cmDspKr.h Переглянути файл

@@ -10,6 +10,7 @@ extern "C" {
10 10
   struct cmDspClass_str* cmScoreClassCons( cmDspCtx_t* ctx );
11 11
   struct cmDspClass_str* cmMidiFilePlayClassCons( cmDspCtx_t* ctx );
12 12
   struct cmDspClass_str* cmScFolClassCons( cmDspCtx_t* ctx );
13
+  struct cmDspClass_str* cmScModClassCons( cmDspCtx_t* ctx );
13 14
 
14 15
 #ifdef __cplusplus
15 16
 }

+ 71
- 11
dsp/cmDspPgmKr.c Переглянути файл

@@ -38,7 +38,7 @@ typedef struct
38 38
   const cmChar_t* tlFn;
39 39
   const cmChar_t* audPath;
40 40
   const cmChar_t* scFn;
41
-  
41
+  const cmChar_t* modFn;
42 42
 } krRsrc_t;
43 43
 
44 44
 cmDspRC_t krLoadRsrc(cmDspSysH_t h, cmErr_t* err, krRsrc_t* r)
@@ -50,6 +50,7 @@ cmDspRC_t krLoadRsrc(cmDspSysH_t h, cmErr_t* err, krRsrc_t* r)
50 50
   cmDspRsrcString(h,&r->tlFn,   "timeLineFn",      NULL);
51 51
   cmDspRsrcString(h,&r->audPath,"tlAudioFilePath", NULL);
52 52
   cmDspRsrcString(h,&r->scFn,   "scoreFn",         NULL);
53
+  cmDspRsrcString(h,&r->modFn,  "modFn",           NULL);
53 54
 
54 55
   if((rc = cmDspSysLastRC(h)) != kOkDspRC )
55 56
     cmErrMsg(err,rc,"A KR DSP resource load failed.");
@@ -66,6 +67,8 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
66 67
   unsigned        wtLoopCnt  = 1;                           // 1=play once (-1=loop forever)
67 68
   unsigned        wtInitMode = 0;                            // initial wt mode is 'silence'
68 69
   unsigned        wtSmpCnt   = floor(cmDspSysSampleRate(h)); // wt length == srate
70
+  int             krWndSmpCnt = 2048;
71
+  int             krHopFact   = 4;
69 72
 
70 73
   memset(&r,0,sizeof(r));
71 74
   cmErrSetup(&err,&cmCtx->rpt,"Kr Timeline");
@@ -80,6 +83,9 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
80 83
   cmDspInst_t* pts  = cmDspSysAllocInst(h,"PortToSym",   NULL,  2, "on", "off" );
81 84
   cmDspInst_t* mfp  = cmDspSysAllocInst(h,"MidiFilePlay",NULL,  0 );
82 85
   cmDspInst_t* sfp  = cmDspSysAllocInst(h,"ScFol",       NULL,  1, r.scFn );
86
+  cmDspInst_t* kr0p = cmDspSysAllocInst(h,"Kr",          NULL,   2, krWndSmpCnt, krHopFact );
87
+  cmDspInst_t* kr1p = cmDspSysAllocInst(h,"Kr",          NULL,   2, krWndSmpCnt, krHopFact );
88
+
83 89
   cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",    NULL,  1, 0 );
84 90
   cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",    NULL,  1, 1 );
85 91
 
@@ -89,14 +95,44 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
89 95
   cmDspInst_t* prtb = cmDspSysAllocInst(h,"Button", "print",  2, kButtonDuiId, 1.0 );
90 96
   cmDspInst_t* qtb  = cmDspSysAllocInst(h,"Button", "quiet",  2, kButtonDuiId, 1.0 );
91 97
   cmDspInst_t* prp  = cmDspSysAllocInst(h,"Printer", NULL,   1, ">" );
92
-  //cmDspInst_t* prd  = cmDspSysAllocInst(h,"Printer", NULL,   1, "DYN:" );
93
-  //cmDspInst_t* pre  = cmDspSysAllocInst(h,"Printer", NULL,   1, "EVEN:" );
98
+  cmDspInst_t* prd  = cmDspSysAllocInst(h,"Printer", NULL,   1, "DYN:" );
99
+  cmDspInst_t* pre  = cmDspSysAllocInst(h,"Printer", NULL,   1, "EVEN:" );
100
+  cmDspInst_t* prt  = cmDspSysAllocInst(h,"Printer", NULL,   1, "TEMPO:");
101
+  //cmDspInst_t* prv  = cmDspSysAllocInst(h,"Printer", NULL,   1, "Value:");
102
+  cmDspSysNewColumn(h,0);
103
+
104
+  cmDspInst_t* md0p = cmDspSysAllocInst(h,"Scalar", "Mode",      5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
105
+  cmDspInst_t* ws0p = cmDspSysAllocInst(h,"MsgList","wndSmpCnt", 3, "wndSmpCnt", NULL, 2);
106
+  cmDspInst_t* hf0p = cmDspSysAllocInst(h,"MsgList","hopFact",   3, "hopFact",   NULL, 2);
107
+  cmDspInst_t* th0p = cmDspSysAllocInst(h,"Scalar", "threshold", 5, kNumberDuiId, 0.0, 100.0, 1.0,  60.0 );
108
+  cmDspInst_t* us0p = cmDspSysAllocInst(h,"Scalar", "upr slope", 5, kNumberDuiId, 0.0,  10.0, 0.01,  0.0 ); 
109
+  cmDspInst_t* ls0p = cmDspSysAllocInst(h,"Scalar", "lwr slope", 5, kNumberDuiId, 0.3,  10.0, 0.01,  2.0 );
110
+  cmDspInst_t* of0p = cmDspSysAllocInst(h,"Scalar", "offset",    5, kNumberDuiId, 0.0, 100.0, 0.01, 30.0 );
111
+  cmDspInst_t* iv0p = cmDspSysAllocInst(h,"Scalar", "invert",    5, kNumberDuiId, 0.0,   1.0, 1.0,   0.0 );  
112
+  cmDspSysNewColumn(h,0);
113
+
114
+  //cmDspInst_t* al1p = cmDspSysAllocInst(h,"MsgList","audFiles", 2, "audFiles",NULL);
115
+  //cmDspInst_t* fl1p = cmDspSysAllocInst(h,"MsgList","audFrags1", 2, "audFrags",NULL);
116
+  //cmDspInst_t* fn1p = cmDspSysAllocInst(h,"Sprintf","filename", 1, "%s/%s_%02i.wav");
117
+  cmDspInst_t* md1p = cmDspSysAllocInst(h,"Scalar", "Mode1",      5, kNumberDuiId, 0.0, 4.0, 1.0, 1.0);
118
+  cmDspInst_t* ws1p = cmDspSysAllocInst(h,"MsgList","wndSmpCnt1", 3, "wndSmpCnt", NULL, 2);
119
+  cmDspInst_t* hf1p = cmDspSysAllocInst(h,"MsgList","hopFact1",   3, "hopFact",   NULL, 2);
120
+  cmDspInst_t* th1p = cmDspSysAllocInst(h,"Scalar", "threshold1", 5, kNumberDuiId, 0.0, 100.0, 1.0,  60.0 );
121
+  cmDspInst_t* us1p = cmDspSysAllocInst(h,"Scalar", "upr slope1", 5, kNumberDuiId, 0.0,  10.0, 0.01,  0.0 ); 
122
+  cmDspInst_t* ls1p = cmDspSysAllocInst(h,"Scalar", "lwr slope1", 5, kNumberDuiId, 0.3,  10.0, 0.01,  2.0 );
123
+  cmDspInst_t* of1p = cmDspSysAllocInst(h,"Scalar", "offset1",    5, kNumberDuiId, 0.0, 100.0, 0.01, 30.0 );
124
+  cmDspInst_t* iv1p = cmDspSysAllocInst(h,"Scalar", "invert1",    5, kNumberDuiId, 0.0,   1.0, 1.0,   0.0 );  
125
+
94 126
 
95 127
   if((rc = cmDspSysLastRC(h)) != kOkDspRC )
96 128
     return rc;
97 129
 
98 130
   // phasor->wt->aout
99 131
   cmDspSysConnectAudio(h, php, "out", wtp,  "phs" );   // phs -> wt
132
+  //cmDspSysConnectAudio(h, wtp, "out", kr0p,  "in"  );  // wt->kr
133
+  //cmDspSysConnectAudio(h, wtp, "out", kr1p,  "in"  );
134
+  //cmDspSysConnectAudio(h, kr0p, "out", ao0p, "in");  // kr->aout- 0
135
+  //cmDspSysConnectAudio(h, kr1p, "out", ao1p, "in"); 
100 136
   cmDspSysConnectAudio(h, wtp, "out", ao0p, "in"  );   // wt  -> aout0
101 137
   cmDspSysConnectAudio(h, wtp, "out", ao1p, "in" );    // wt  -> aout1
102 138
  
@@ -132,18 +168,37 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
132 168
 
133 169
   // MIDI file player to score-follower and score - the order of connections is the same
134 170
   // as the msg transmision order from MFP
135
-  cmDspSysInstallCb(h, mfp, "smpidx", scp, "smpidx", NULL );
136
-  cmDspSysInstallCb(h, mfp, "d1",     scp, "d1",     NULL );
171
+  //cmDspSysInstallCb(h, mfp, "smpidx", scp, "smpidx", NULL );
172
+  cmDspSysInstallCb(h, mfp, "smpidx", sfp, "smpidx", NULL );
173
+  //cmDspSysInstallCb(h, mfp, "d1",     scp, "d1",     NULL );
137 174
   cmDspSysInstallCb(h, mfp, "d1",     sfp, "d1",     NULL );
138
-  cmDspSysInstallCb(h, mfp, "d0",     scp, "d0",     NULL );
175
+  //cmDspSysInstallCb(h, mfp, "d0",     scp, "d0",     NULL );
139 176
   cmDspSysInstallCb(h, mfp, "d0",     sfp, "d0",     NULL );
140
-  cmDspSysInstallCb(h, mfp, "status", scp, "status", NULL );
177
+  //cmDspSysInstallCb(h, mfp, "status", scp, "status", NULL );
141 178
   cmDspSysInstallCb(h, mfp, "status", sfp, "status", NULL );
142 179
 
143 180
 
144 181
   // score follower to score
145
-  cmDspSysInstallCb(h, sfp, "out",  scp, "loc", NULL );
146
-
182
+  //cmDspSysInstallCb(h, sfp, "out",  modp, "index", NULL );
183
+
184
+
185
+  cmDspSysInstallCb(h, ws0p, "out", kr0p, "wndn", NULL );   // wndSmpCnt->kr
186
+  cmDspSysInstallCb(h, hf0p, "out", kr0p, "hopf", NULL );   // hopFact->kr
187
+  cmDspSysInstallCb(h, md0p, "val", kr0p, "mode", NULL );   // mode->kr
188
+  cmDspSysInstallCb(h, th0p, "val", kr0p, "thrh", NULL );   // thresh->kr
189
+  cmDspSysInstallCb(h, ls0p, "val", kr0p, "lwrs", NULL );   // lwrSlope->kr
190
+  cmDspSysInstallCb(h, us0p, "val", kr0p, "uprs", NULL );   // uprSlope->kr
191
+  cmDspSysInstallCb(h, of0p, "val", kr0p, "offs", NULL );   // offset->kr
192
+  cmDspSysInstallCb(h, iv0p, "val", kr0p, "invt", NULL );   // invert->kr
193
+
194
+  cmDspSysInstallCb(h, ws1p, "out", kr1p, "wndn", NULL );   // wndSmpCnt->kr
195
+  cmDspSysInstallCb(h, hf1p, "out", kr1p, "hopf", NULL );   // hopFact->kr
196
+  cmDspSysInstallCb(h, md1p, "val", kr1p, "mode", NULL );   // mode->kr
197
+  cmDspSysInstallCb(h, th1p, "val", kr1p, "thrh", NULL );   // thresh->kr
198
+  cmDspSysInstallCb(h, ls1p, "val", kr1p, "lwrs", NULL );   // lwrSlope->kr
199
+  cmDspSysInstallCb(h, us1p, "val", kr1p, "uprs", NULL );   // uprSlope->kr
200
+  cmDspSysInstallCb(h, of1p, "val", kr1p, "offs", NULL );   // offset->kr
201
+  cmDspSysInstallCb(h, iv1p, "val", kr1p, "invt", NULL );   // invert->kr
147 202
 
148 203
   // Printer connections
149 204
   cmDspSysInstallCb(h, tlp, "afn",  prp, "in",  NULL );
@@ -151,8 +206,13 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
151 206
   cmDspSysInstallCb(h, tlp, "sel",  prp, "in",  NULL );
152 207
   cmDspSysInstallCb(h, sfp, "out",  prp, "in",     NULL );
153 208
 
154
-  //cmDspSysInstallCb(h, scp, "even", pre, "in", NULL );
155
-  //cmDspSysInstallCb(h, scp, "dyn",  prd, "in", NULL );
209
+  cmDspSysInstallCb(h, sfp, "even", pre, "in", NULL );
210
+  cmDspSysInstallCb(h, sfp, "dyn",  prd, "in", NULL );
211
+  cmDspSysInstallCb(h, sfp, "tempo",prt, "in", NULL );
212
+  //cmDspSysInstallCb(h, modp,"v0",   prv, "in", NULL );
213
+  //cmDspSysInstallCb(h, modp,"v1",   prv, "in", NULL );
214
+  //cmDspSysInstallCb(h, modp,"v2",   prv, "in", NULL );
215
+
156 216
 
157 217
   cmDspSysInstallCb(h, prtb, "sym", sfp, "cmd", NULL );
158 218
   cmDspSysInstallCb(h, qtb,  "sym", sfp, "cmd", NULL );

Завантаження…
Відмінити
Зберегти