Browse Source

cmDspFx.c : Added 'reset' input to cmDspXFader and cmDspAvailCh objects.

master
kevin 11 years ago
parent
commit
b67964871f
1 changed files with 58 additions and 3 deletions
  1. 58
    3
      dsp/cmDspFx.c

+ 58
- 3
dsp/cmDspFx.c View File

1423
   kMstrGateXfId,
1423
   kMstrGateXfId,
1424
   kFadeInTimeMsXfId,
1424
   kFadeInTimeMsXfId,
1425
   kFadeOutTimeMsXfId,
1425
   kFadeOutTimeMsXfId,
1426
+  kResetXfId,
1426
   kOnXfId,
1427
   kOnXfId,
1427
   kOffXfId,
1428
   kOffXfId,
1428
   kGateBaseXfId,
1429
   kGateBaseXfId,
1453
     { "mgate", kMstrGateXfId,      0, 0,   kInDsvFl  | kBoolDsvFl   | kOptArgDsvFl, "Master gate - can be used to set all gates."},
1454
     { "mgate", kMstrGateXfId,      0, 0,   kInDsvFl  | kBoolDsvFl   | kOptArgDsvFl, "Master gate - can be used to set all gates."},
1454
     { "ims",   kFadeInTimeMsXfId,  0, 0,   kInDsvFl  | kDoubleDsvFl | kOptArgDsvFl, "Fade in time in milliseonds."},
1455
     { "ims",   kFadeInTimeMsXfId,  0, 0,   kInDsvFl  | kDoubleDsvFl | kOptArgDsvFl, "Fade in time in milliseonds."},
1455
     { "oms",   kFadeOutTimeMsXfId, 0, 0,   kInDsvFl  | kDoubleDsvFl | kOptArgDsvFl, "Fade out time in milliseonds."},
1456
     { "oms",   kFadeOutTimeMsXfId, 0, 0,   kInDsvFl  | kDoubleDsvFl | kOptArgDsvFl, "Fade out time in milliseonds."},
1457
+    { "reset", kResetXfId,         0, 0,   kInDsvFl  | kBoolDsvFl,                  "Jump to gate states rather than fade."},
1456
     { "on",    kOnXfId,            0, 0,   kOutDsvFl | kSymDsvFl,                   "Send 'on' when all ch's transition from off to on."},
1458
     { "on",    kOnXfId,            0, 0,   kOutDsvFl | kSymDsvFl,                   "Send 'on' when all ch's transition from off to on."},
1457
     { "off",   kOffXfId,           0, 0,   kOutDsvFl | kSymDsvFl,                   "Send 'off' when all ch's transition from on to off."},
1459
     { "off",   kOffXfId,           0, 0,   kOutDsvFl | kSymDsvFl,                   "Send 'off' when all ch's transition from on to off."},
1458
   };
1460
   };
1551
     cmSample_t*       op = cmDspAudioBuf(ctx,inst,p->outBaseXfId+i,0);
1553
     cmSample_t*       op = cmDspAudioBuf(ctx,inst,p->outBaseXfId+i,0);
1552
     const cmSample_t* ip = cmDspAudioBuf(ctx,inst,p->inBaseXfId+i,0);
1554
     const cmSample_t* ip = cmDspAudioBuf(ctx,inst,p->inBaseXfId+i,0);
1553
     cmSample_t        gain = (cmSample_t)p->xfdp->chArray[i].ep_gain;
1555
     cmSample_t        gain = (cmSample_t)p->xfdp->chArray[i].ep_gain;
1554
-    
1556
+
1555
     if( op != NULL )
1557
     if( op != NULL )
1556
     {
1558
     {
1557
       if( ip == NULL )
1559
       if( ip == NULL )
1568
 
1570
 
1569
     // send the gain output
1571
     // send the gain output
1570
     cmDspSetDouble(ctx,inst,p->gainBaseXfId+i,gain);
1572
     cmDspSetDouble(ctx,inst,p->gainBaseXfId+i,gain);
1573
+
1574
+    /*
1575
+    if( gain > 0 )
1576
+      printf("(%i %f %i %i %i %f)",
1577
+        i,
1578
+        gain,
1579
+        p->chGateV[i],
1580
+        cmDspBool(inst,p->stateBaseXfId+i),
1581
+        p->xfdp->chArray[i].gateFl,
1582
+        p->xfdp->chArray[i].gain);
1583
+    */
1584
+
1585
+
1571
   }
1586
   }
1572
 
1587
 
1573
   if( p->xfdp->onFl )
1588
   if( p->xfdp->onFl )
1611
       cmXfaderSetXfadeOutTime(p->xfdp,cmDspDouble(inst,kFadeOutTimeMsXfId));
1626
       cmXfaderSetXfadeOutTime(p->xfdp,cmDspDouble(inst,kFadeOutTimeMsXfId));
1612
       break;
1627
       break;
1613
 
1628
 
1629
+    case kResetXfId:
1630
+      {
1631
+        cmXfaderExec( p->xfdp, cmDspSamplesPerCycle(ctx), p->chGateV, p->chCnt );
1632
+        cmXfaderJumpToDestinationGain(p->xfdp);
1633
+        // force the chGateV[] to match the xfaders state
1634
+        int i;
1635
+        for(i=0; i<p->chCnt; ++i)
1636
+        {
1637
+          bool gateFl = p->xfdp->chArray[i].gateFl;
1638
+          p->chGateV[i] = gateFl;
1639
+          cmDspSetBool(  ctx,inst,p->stateBaseXfId + i, gateFl);
1640
+          cmDspSetDouble(ctx,inst,p->gainBaseXfId  + i, gateFl ? 1.0 : 0.0 );          
1641
+        }
1642
+      }
1643
+      break;
1644
+
1614
   }
1645
   }
1615
   
1646
   
1616
   // record gate changes into p->chGateV[] for later use in _cmDspXfaderExec().
1647
   // record gate changes into p->chGateV[] for later use in _cmDspXfaderExec().
5744
   kChCntAvId,
5775
   kChCntAvId,
5745
   kModeAvId,
5776
   kModeAvId,
5746
   kTrigAvId,
5777
   kTrigAvId,
5778
+  kResetAvId,
5747
   kChIdxAvId,  
5779
   kChIdxAvId,  
5748
   kBaseDisInAvId,
5780
   kBaseDisInAvId,
5749
 
5781
 
5789
     1,         "chs",    kChCntAvId,        0, 0, kUIntDsvFl     | kReqArgDsvFl, "Channel count.",
5821
     1,         "chs",    kChCntAvId,        0, 0, kUIntDsvFl     | kReqArgDsvFl, "Channel count.",
5790
     1,         "mode",   kModeAvId,         0, 0, kUIntDsvFl     | kInDsvFl,     "Mode: 0=exclusive (dflt) 1=multi",
5822
     1,         "mode",   kModeAvId,         0, 0, kUIntDsvFl     | kInDsvFl,     "Mode: 0=exclusive (dflt) 1=multi",
5791
     1,         "trig",   kTrigAvId,         0, 0, kTypeDsvMask   | kInDsvFl,     "Trigger the unit to select the next available channel.", 
5823
     1,         "trig",   kTrigAvId,         0, 0, kTypeDsvMask   | kInDsvFl,     "Trigger the unit to select the next available channel.", 
5824
+    1,         "reset",  kResetAvId,        0, 0, kBoolDsvFl     | kInDsvFl | kOutDsvFl,     "Reset to default state",
5792
     1,         "ch",     kChIdxAvId,        0, 0, kUIntDsvFl     | kOutDsvFl,    "Currently selected channel.",
5825
     1,         "ch",     kChIdxAvId,        0, 0, kUIntDsvFl     | kOutDsvFl,    "Currently selected channel.",
5793
     chCnt,     "dis",    baseDisInAvId,     0, 0, kBoolDsvFl     | kInDsvFl,     "Disable channel gate",
5826
     chCnt,     "dis",    baseDisInAvId,     0, 0, kBoolDsvFl     | kInDsvFl,     "Disable channel gate",
5794
     chCnt,     "gate",   baseGateOutAvId,   0, 0, kBoolDsvFl     | kOutDsvFl,    "Active channel gate",
5827
     chCnt,     "gate",   baseGateOutAvId,   0, 0, kBoolDsvFl     | kOutDsvFl,    "Active channel gate",
5831
 
5864
 
5832
   bool exclModeFl  = cmDspUInt(inst, kModeAvId ) == kExclusiveModeAvId;
5865
   bool exclModeFl  = cmDspUInt(inst, kModeAvId ) == kExclusiveModeAvId;
5833
 
5866
 
5867
+  if( evt->dstVarId == kResetAvId )
5868
+  {
5869
+    unsigned i;      
5870
+
5871
+    cmDspSetUInt(ctx,inst,kChIdxAvId,0);
5872
+
5873
+    for(i=0; i<p->chCnt; ++i)
5874
+    {
5875
+      bool fl = i==0;
5876
+      cmDspSetBool(ctx, inst, p->baseDisInAvId   + i, !fl);
5877
+      cmDspSetBool(ctx, inst, p->baseGateOutAvId + i, fl);
5878
+    }
5879
+
5880
+    cmDspSetBool(ctx,inst, kResetAvId, false );
5881
+
5882
+    return rc;
5883
+  }
5884
+
5834
   // if this is a trigger
5885
   // if this is a trigger
5835
   if( evt->dstVarId == kTrigAvId )
5886
   if( evt->dstVarId == kTrigAvId )
5836
   {
5887
   {
5837
-    unsigned i;
5888
+    unsigned i,j=-1;
5838
     bool     fl = true;
5889
     bool     fl = true;
5839
     for(i=0; i<p->chCnt; ++i)
5890
     for(i=0; i<p->chCnt; ++i)
5840
     {
5891
     {
5841
-      // the actual channel's active state is held in the 'dis' variable.
5892
+      // the channel's active state is held in the 'dis' variable.
5842
       bool activeFl = cmDspBool(inst,p->baseDisInAvId+i);
5893
       bool activeFl = cmDspBool(inst,p->baseDisInAvId+i);
5843
 
5894
 
5844
       // if ch[i] is the first avail inactive channel
5895
       // if ch[i] is the first avail inactive channel
5847
         cmDspSetUInt(ctx,inst,kChIdxAvId,i);
5898
         cmDspSetUInt(ctx,inst,kChIdxAvId,i);
5848
         cmDspSetBool(ctx, inst, p->baseDisInAvId   + i, true);
5899
         cmDspSetBool(ctx, inst, p->baseDisInAvId   + i, true);
5849
         cmDspSetBool(ctx, inst, p->baseGateOutAvId + i, true);
5900
         cmDspSetBool(ctx, inst, p->baseGateOutAvId + i, true);
5901
+        j = i;
5850
         fl = false;
5902
         fl = false;
5851
       }
5903
       }
5852
 
5904
 
5855
         cmDspSetBool(ctx, inst, p->baseGateOutAvId + i, false);
5907
         cmDspSetBool(ctx, inst, p->baseGateOutAvId + i, false);
5856
 
5908
 
5857
     }
5909
     }
5910
+
5858
     return rc;
5911
     return rc;
5859
   }
5912
   }
5860
 
5913
 
5914
+  
5915
+
5861
   // if this is an incoming disable message.
5916
   // if this is an incoming disable message.
5862
   if( p->baseDisInAvId <= evt->dstVarId && evt->dstVarId < p->baseDisInAvId+p->chCnt && cmDsvGetBool(evt->valuePtr) == false)
5917
   if( p->baseDisInAvId <= evt->dstVarId && evt->dstVarId < p->baseDisInAvId+p->chCnt && cmDsvGetBool(evt->valuePtr) == false)
5863
   {
5918
   {

Loading…
Cancel
Save