Pārlūkot izejas kodu

cmProcr4.c : Added 'postFl' to scMod.

master
kevin 11 gadus atpakaļ
vecāks
revīzija
27c719dcc4
2 mainītis faili ar 23 papildinājumiem un 122 dzēšanām
  1. 19
    121
      cmProc4.c
  2. 4
    1
      cmProc4.h

+ 19
- 121
cmProc4.c Parādīt failu

@@ -3420,6 +3420,7 @@ _cmScModTypeMap_t _cmScModTypeArray[] =
3420 3420
   { kSetModTId,     1, "set" },
3421 3421
   { kLineModTId,    2, "line" },
3422 3422
   { kSetLineModTId, 3, "sline" },
3423
+  { kPostModTId,    4, "post" },
3423 3424
   { kInvalidModTId, 0, "<invalid>"}
3424 3425
 };
3425 3426
 
@@ -3535,121 +3536,6 @@ cmScModEntry_t* _cmScModulatorInsertEntry(cmScModulator* p, unsigned idx, unsign
3535 3536
   return rc;
3536 3537
 }
3537 3538
 
3538
-/*
3539
-cmRC_t _cmScModulatorParse2( cmScModulator* p, cmCtx_t* ctx, cmSymTblH_t stH, const cmChar_t* fn )
3540
-{
3541
-  cmRC_t        rc  = cmOkRC;
3542
-  cmJsonNode_t* jnp = NULL;
3543
-  cmJsonH_t     jsH = cmJsonNullHandle;
3544
-  unsigned      i   = cmInvalidIdx;
3545
-  unsigned      j   = cmInvalidIdx;
3546
-
3547
-  // read the JSON file
3548
-  if( cmJsonInitializeFromFile(&jsH, fn, ctx ) != kOkJsRC )
3549
-    return cmCtxRtCondition( &p->obj, cmInvalidArgRC, "JSON file parse failed on the modulator file: %s.",cmStringNullGuard(fn) );
3550
-
3551
-  jnp = cmJsonRoot(jsH);
3552
-
3553
-  // validate that the first child as an array
3554
-  if( jnp==NULL || ((jnp = cmJsonNodeMemberValue(jnp,"array")) == NULL) || cmJsonIsArray(jnp)==false )
3555
-  {
3556
-    rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Modulator file header syntax error in file:%s",cmStringNullGuard(fn) );
3557
-    goto errLabel;
3558
-  }
3559
-
3560
-  // allocate the entry array
3561
-  unsigned entryCnt = cmJsonChildCount(jnp);
3562
-  p->earray         = cmMemResizeZ(cmScModEntry_t,p->earray,entryCnt);
3563
-  p->en             = entryCnt;
3564
-
3565
-  for(i=0; i<entryCnt; ++i)
3566
-  {
3567
-    cmJsRC_t                 jsRC;
3568
-    const char*              errLabelPtr = NULL;
3569
-    unsigned                 scLocIdx    = cmInvalidIdx;
3570
-    const cmChar_t*          modLabel    = NULL;
3571
-    const cmChar_t*          varLabel    = NULL;
3572
-    const cmChar_t*          typeLabel   = NULL;
3573
-    cmJsonNode_t*            onp         = cmJsonArrayElement(jnp,i);
3574
-    cmJsonNode_t*            dnp         = NULL;
3575
-    const _cmScModTypeMap_t* map         = NULL;
3576
-
3577
-    if((jsRC = cmJsonMemberValues( onp, &errLabelPtr, 
3578
-          "loc", kIntTId,    &scLocIdx,
3579
-          "mod", kStringTId, &modLabel,
3580
-          "var", kStringTId, &varLabel,
3581
-          "type",kStringTId, &typeLabel,
3582
-          NULL )) != kOkJsRC )
3583
-    {
3584
-      if( errLabelPtr == NULL )
3585
-        rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Error:%s on record at index %i in file:%s",errLabelPtr,i,cmStringNullGuard(fn) );
3586
-      else
3587
-        rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Synax error in Modulator record at index %i in file:%s",i,cmStringNullGuard(fn) );
3588
-      goto errLabel;
3589
-    }
3590
-
3591
-    // validate the entry type label
3592
-    if((map = _cmScModTypeLabelToMap(typeLabel)) == NULL )
3593
-    {
3594
-      rc = cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Unknown entry type '%s' in Modulator record at index %i in file:%s",cmStringNullGuard(typeLabel),i,cmStringNullGuard(fn) );
3595
-      goto errLabel;
3596
-    }
3597
-    
3598
-    unsigned modSymId = cmSymTblRegisterSymbol(stH,modLabel);
3599
-    unsigned varSymId = cmSymTblRegisterSymbol(stH,varLabel);
3600
-
3601
-    // the mod entry label must match the modulators label
3602
-    if( p->modSymId != modSymId )
3603
-    {
3604
-      --p->en;
3605
-        continue;
3606
-    } 
3607
-
3608
-
3609
-    // get the count of the elmenets in the data array
3610
-    unsigned paramCnt = cmJsonChildCount(onp);
3611
-
3612
-    // fill the entry record and find or create the target var
3613
-    cmScModEntry_t* ep = _cmScModulatorInsertEntry(p,i,scLocIdx,modSymId,varSymId,map->typeId,paramCnt);
3614
-
3615
-    typedef struct
3616
-    {
3617
-      const cmChar_t* label;
3618
-      cmScModParam_t* param;
3619
-    } map_t;
3620
-
3621
-    // parse the var and parameter records
3622
-    map_t mapArray[] = 
3623
-    {
3624
-      { "min", &ep->min  },
3625
-      { "max", &ep->max  },
3626
-      { "rate",&ep->rate },
3627
-      { "val", &ep->beg },
3628
-      { "end", &ep->end },
3629
-      { "dur", &ep->dur },
3630
-      { NULL, NULL }
3631
-    };
3632
-
3633
-    unsigned j=0;
3634
-    for(j=0; mapArray[j].param!=NULL; ++j)
3635
-      if((dnp = cmJsonFindValue(jsH,mapArray[j].label, onp, kInvalidTId )) != NULL )
3636
-        if((rc = _cmScModulatorParseParam(p,stH,dnp,mapArray[j].param)) != cmOkRC )
3637
-          goto errLabel;    
3638
-  }
3639
-
3640
- errLabel:
3641
-
3642
-  if( rc != cmOkRC )
3643
-    cmCtxRtCondition( &p->obj, cmInvalidArgRC, "Error parsing in Modulator 'data' record at index %i value index %i in file:%s",i,j,cmStringNullGuard(fn) );    
3644
-
3645
-
3646
-  // release the JSON tree
3647
-  if( cmJsonIsValid(jsH) )
3648
-    cmJsonFinalize(&jsH);
3649
-
3650
-  return rc;
3651
-}
3652
-*/
3653 3539
 
3654 3540
 cmRC_t _cmScModulatorParse( cmScModulator* p, cmCtx_t* ctx, cmSymTblH_t stH, const cmChar_t* fn )
3655 3541
 {
@@ -4016,6 +3902,10 @@ cmRC_t _cmScModActivate(cmScModulator* p, cmScModEntry_t* ep )
4016 3902
       vp->phase  = 0;                          // reset phase
4017 3903
       break;
4018 3904
 
3905
+    case kPostModTId:
3906
+      p->postFl = vp->value;
3907
+      break;
3908
+
4019 3909
     default:
4020 3910
       { assert(0); }
4021 3911
   }
@@ -4040,7 +3930,7 @@ cmRC_t  _cmScModExecSendValue( cmScModulator* p, cmScModVar_t* vp )
4040 3930
     sendFl = remainder(vp->phase*p->samplesPerCycle, p->srate*vp->rate/1000 ) < p->samplesPerCycle;
4041 3931
 
4042 3932
   if(sendFl)
4043
-    p->cbFunc(p->cbArg,vp->varSymId,v);
3933
+    p->cbFunc(p->cbArg,vp->varSymId,v,p->postFl);
4044 3934
 
4045 3935
   return rc;
4046 3936
 }
@@ -4048,8 +3938,9 @@ cmRC_t  _cmScModExecSendValue( cmScModulator* p, cmScModVar_t* vp )
4048 3938
 // Return true if vp should be deactivated otherwise return false.
4049 3939
 bool  _cmScModExec( cmScModulator* p, cmScModVar_t* vp )
4050 3940
 {
4051
-  cmRC_t rc = cmOkRC;
4052
-  bool   fl = false;
3941
+  cmRC_t rc     = cmOkRC;
3942
+  bool   fl     = false;
3943
+  bool   sendFl = true;
4053 3944
 
4054 3945
   switch( vp->entry->typeId )
4055 3946
   {
@@ -4085,15 +3976,22 @@ bool  _cmScModExec( cmScModulator* p, cmScModVar_t* vp )
4085 3976
       }
4086 3977
       break;
4087 3978
 
3979
+    case kPostModTId:
3980
+      sendFl = false;
3981
+      break;
3982
+
4088 3983
     default:
4089 3984
       { assert(0); }
4090 3985
   }
4091 3986
 
4092 3987
   // notify the application that a new variable value has been generated
4093
-  rc = _cmScModExecSendValue(p,vp);
3988
+  if(sendFl)
3989
+  {
3990
+    rc = _cmScModExecSendValue(p,vp);
4094 3991
 
4095
-  // increment the phase - after send because send notices when phase is zero
4096
-  vp->phase += 1;
3992
+    // increment the phase - after send because send notices when phase is zero
3993
+    vp->phase += 1;
3994
+  }
4097 3995
 
4098 3996
  errLabel:
4099 3997
   if( rc != cmOkRC )

+ 4
- 1
cmProc4.h Parādīt failu

@@ -518,6 +518,7 @@ Types:
518 518
   set    = set <var> to <val> which may be a literal or another variable.
519 519
   line   = ramp from its current value to <val> over <dur> seconds
520 520
   sline  = set <var> to <val> and ramp to <end> over <dur> seconds
521
+  post   = send a 'post' msg after each transmission (can be used to change the cross-fader after each msg)
521 522
 
522 523
  */
523 524
 enum
@@ -526,6 +527,7 @@ enum
526 527
   kSetModTId,      // set variable to parray[0] at scLocIdx
527 528
   kLineModTId,     // linear ramp variable to parray[0] over parray[1] seconds
528 529
   kSetLineModTId,  // set variable to parray[0] and ramp to parray[1] over parray[2] seconds
530
+  kPostModTId,     // 
529 531
 };
530 532
 
531 533
 enum
@@ -583,7 +585,7 @@ typedef struct cmScModEntry_str
583 585
   cmScModVar_t*  varPtr;        // target variable 
584 586
 } cmScModEntry_t;
585 587
 
586
-typedef void (*cmScModCb_t)( void* cbArg, unsigned varSymId, double value );
588
+  typedef void (*cmScModCb_t)( void* cbArg, unsigned varSymId, double value, bool postFl );
587 589
 
588 590
 typedef struct
589 591
 {
@@ -602,6 +604,7 @@ typedef struct
602 604
   cmScModVar_t*   elist;        // last element on the active list
603 605
   unsigned        nei;          // next entry index
604 606
   unsigned        outVarCnt;    // count of unique vars that are targets of entry recds
607
+  bool            postFl;       // send a 'post' msg after each transmission
605 608
 } cmScModulator;
606 609
 
607 610
 

Notiek ielāde…
Atcelt
Saglabāt