Logo Search packages:      
Sourcecode: guitarix version File versions  Download package

distortion1.cc

namespace distortion1 {
// generated from file '../src/faust/distortion1.dsp'

int   iVec0[2];
double      fConst0;
double      fConst1;
double      fConst2;
double      fConst3;
double      fConst4;
double      fConst5;
double      fConst6;
FAUSTFLOAT  fslider0;
double      fRec1[2];
double      fRec4[2];
FAUSTFLOAT  fslider1;
int   IOTA;
double      fVec1[4096];
FAUSTFLOAT  fslider2;
double      fRec5[2];
FAUSTFLOAT  fcheckbox0;
FAUSTFLOAT  fentry0;
double      fConst7;
double      fVec2[2];
double      fRec7[2];
FAUSTFLOAT  fentry1;
double      fConst8;
double      fConst9;
double      fVec3[2];
double      fRec6[2];
FAUSTFLOAT  fcheckbox1;
FAUSTFLOAT  fslider3;
FAUSTFLOAT  fslider4;
double      fVec4[2];
double      fRec11[2];
double      fVec5[2];
double      fRec10[2];
double      fRec9[3];
double      fRec8[3];
FAUSTFLOAT  fcheckbox2;
double      fVec6[3];
double      fConst10;
double      fConst11;
double      fConst12;
double      fConst13;
double      fConst14;
double      fRec3[3];
FAUSTFLOAT  fslider5;
FAUSTFLOAT  fslider6;
double      fVec7[2];
double      fRec2[2];
double      fVec8[3];
double      fRec0[3];
double      fVec9[2];
double      fRec15[2];
double      fVec10[2];
double      fRec14[2];
double      fRec13[3];
double      fRec12[3];
int   fSamplingFreq;

void init(int samplingFreq)
{
      fSamplingFreq = samplingFreq;
      for (int i=0; i<2; i++) iVec0[i] = 0;
      fConst0 = (6.283185307179586 * (max(0, ((0.5 * fSamplingFreq) - 1e+02)) / fSamplingFreq));
      fConst1 = cos(fConst0);
      fConst2 = (1.316227766016838 * fConst1);
      fConst3 = (0 - (2 * (0 - (0.683772233983162 + fConst2))));
      fConst4 = (0.683772233983162 * fConst1);
      fConst5 = (0.005623413251903491 * sin(fConst0));
      fConst6 = (fConst5 - (fConst4 + 1.316227766016838));
      for (int i=0; i<2; i++) fRec1[i] = 0;
      for (int i=0; i<2; i++) fRec4[i] = 0;
      IOTA = 0;
      for (int i=0; i<4096; i++) fVec1[i] = 0;
      for (int i=0; i<2; i++) fRec5[i] = 0;
      fConst7 = (3.141592653589793 / fSamplingFreq);
      for (int i=0; i<2; i++) fVec2[i] = 0;
      for (int i=0; i<2; i++) fRec7[i] = 0;
      fConst8 = (3.141592653589793 * fSamplingFreq);
      fConst9 = (0.5 / fSamplingFreq);
      for (int i=0; i<2; i++) fVec3[i] = 0;
      for (int i=0; i<2; i++) fRec6[i] = 0;
      for (int i=0; i<2; i++) fVec4[i] = 0;
      for (int i=0; i<2; i++) fRec11[i] = 0;
      for (int i=0; i<2; i++) fVec5[i] = 0;
      for (int i=0; i<2; i++) fRec10[i] = 0;
      for (int i=0; i<3; i++) fRec9[i] = 0;
      for (int i=0; i<3; i++) fRec8[i] = 0;
      for (int i=0; i<3; i++) fVec6[i] = 0;
      fConst10 = (fConst5 + fConst4);
      fConst11 = (0.31622776601683794 * (1.316227766016838 - fConst10));
      fConst12 = (0.31622776601683794 * ((fConst5 + 1.316227766016838) - fConst4));
      fConst13 = (0 - (0.6324555320336759 * (fConst2 - 0.683772233983162)));
      fConst14 = (1.0 / (1.316227766016838 + fConst10));
      for (int i=0; i<3; i++) fRec3[i] = 0;
      for (int i=0; i<2; i++) fVec7[i] = 0;
      for (int i=0; i<2; i++) fRec2[i] = 0;
      for (int i=0; i<3; i++) fVec8[i] = 0;
      for (int i=0; i<3; i++) fRec0[i] = 0;
      for (int i=0; i<2; i++) fVec9[i] = 0;
      for (int i=0; i<2; i++) fRec15[i] = 0;
      for (int i=0; i<2; i++) fVec10[i] = 0;
      for (int i=0; i<2; i++) fRec14[i] = 0;
      for (int i=0; i<3; i++) fRec13[i] = 0;
      for (int i=0; i<3; i++) fRec12[i] = 0;
}

void compute(int count, float *input0, float *output0)
{
      double      fSlow0 = (0.0010000000000000009 * pow(10,(0.05 * (fslider0 - 10))));
      double      fSlow1 = (1.0 - fslider1);
      double      fSlow2 = fslider2;
      int   iSlow3 = int((int((fSlow2 - 1)) & 4095));
      int   iSlow4 = int((int(fSlow2) & 4095));
      int   iSlow5 = int(fcheckbox0);
      double      fSlow6 = (1.0 / tan((fConst7 * fentry0)));
      double      fSlow7 = (fSlow6 - 1);
      double      fSlow8 = (1.0 / (1 + fSlow6));
      double      fSlow9 = (1.0 / tan((fConst9 * (fConst8 - (6.283185307179586 * fentry1)))));
      double      fSlow10 = (1 + fSlow9);
      double      fSlow11 = (1.0 / fSlow10);
      double      fSlow12 = (0 - ((fSlow9 - 1) / fSlow10));
      int   iSlow13 = int(fcheckbox1);
      double      fSlow14 = tan((fConst7 * fslider3));
      double      fSlow15 = (2 * (1 - (1.0 / faustpower<2>(fSlow14))));
      double      fSlow16 = (1.0 / fSlow14);
      double      fSlow17 = (1 + ((fSlow16 - 0.76536686473018) / fSlow14));
      double      fSlow18 = (1.0 / (1 + ((0.76536686473018 + fSlow16) / fSlow14)));
      double      fSlow19 = (1 + ((fSlow16 - 1.847759065022573) / fSlow14));
      double      fSlow20 = (1.0 / (1 + ((1.847759065022573 + fSlow16) / fSlow14)));
      double      fSlow21 = (fConst7 * fslider4);
      double      fSlow22 = (1.0 / (1 + fSlow21));
      double      fSlow23 = (1 - fSlow21);
      int   iSlow24 = int(fcheckbox2);
      double      fSlow25 = fslider5;
      double      fSlow26 = pow(1e+01,(2 * fslider6));
      for (int i=0; i<count; i++) {
            iVec0[0] = 1;
            fRec1[0] = (fSlow0 + (0.999 * fRec1[1]));
            fRec4[0] = ((1e-20 * (1 - iVec0[1])) - fRec4[1]);
            double fTemp0 = (double)input0[i];
            double fTemp1 = (fTemp0 + (fSlow1 * fRec5[1]));
            fVec1[IOTA&4095] = fTemp1;
            fRec5[0] = (0.5 * (fVec1[(IOTA-iSlow4)&4095] + fVec1[(IOTA-iSlow3)&4095]));
            double fTemp2 = ((iSlow5)?fRec5[0]:fTemp0);
            double fTemp3 = (fTemp2 + (2 * fRec4[0]));
            fVec2[0] = (fSlow8 * fTemp3);
            fRec7[0] = (fVec2[1] + (fSlow8 * (fTemp3 + (fSlow7 * fRec7[1]))));
            double fTemp4 = (fSlow11 * fRec7[0]);
            fVec3[0] = fTemp4;
            fRec6[0] = ((fVec3[0] + (fSlow12 * fRec6[1])) - fVec3[1]);
            double fTemp5 = ((iSlow13)?fRec6[0]:(fTemp2 + fRec4[0]));
            double fTemp6 = (1e-20 + (fRec4[0] + fTemp5));
            fVec4[0] = (fSlow22 * fTemp6);
            fRec11[0] = ((fSlow22 * (fTemp6 + (fSlow23 * fRec11[1]))) - fVec4[1]);
            fVec5[0] = (fSlow22 * fRec11[0]);
            fRec10[0] = ((fSlow22 * (fRec11[0] + (fSlow23 * fRec10[1]))) - fVec5[1]);
            fRec9[0] = (fRec10[0] - (fSlow20 * ((fSlow19 * fRec9[2]) + (fSlow15 * fRec9[1]))));
            fRec8[0] = ((fSlow20 * (fRec9[2] + (fRec9[0] + (2 * fRec9[1])))) - (fSlow18 * ((fSlow17 * fRec8[2]) + (fSlow15 * fRec8[1]))));
            double fTemp7 = ((iSlow24)?(fSlow18 * (fRec8[2] + (fRec8[0] + (2 * fRec8[1])))):(1e-20 + fTemp5));
            fVec6[0] = fTemp7;
            fRec3[0] = (fConst14 * ((((fConst13 * fVec6[1]) + (fConst12 * fVec6[0])) + (fConst11 * fVec6[2])) + ((fConst6 * fRec3[2]) + (fConst3 * fRec3[1]))));
            double fTemp8 = max(-1, min(1, (fSlow26 * (fSlow25 + fRec3[0]))));
            double fTemp9 = (fTemp8 * (1 - (0.3333333333333333 * faustpower<2>(fTemp8))));
            fVec7[0] = fTemp9;
            fRec2[0] = ((fVec7[0] + (0.995 * fRec2[1])) - fVec7[1]);
            double fTemp10 = (fRec2[0] * fRec1[0]);
            fVec8[0] = fTemp10;
            fRec0[0] = (fConst14 * ((((fConst13 * fVec8[1]) + (fConst12 * fVec8[0])) + (fConst11 * fVec8[2])) + ((fConst6 * fRec0[2]) + (fConst3 * fRec0[1]))));
            double fTemp11 = (fRec4[0] + fRec0[0]);
            fVec9[0] = (fSlow22 * fTemp11);
            fRec15[0] = ((fSlow22 * (fTemp11 + (fSlow23 * fRec15[1]))) - fVec9[1]);
            fVec10[0] = (fSlow22 * fRec15[0]);
            fRec14[0] = ((fSlow22 * (fRec15[0] + (fSlow23 * fRec14[1]))) - fVec10[1]);
            fRec13[0] = (fRec14[0] - (fSlow20 * ((fSlow19 * fRec13[2]) + (fSlow15 * fRec13[1]))));
            fRec12[0] = ((fSlow20 * (fRec13[2] + (fRec13[0] + (2 * fRec13[1])))) - (fSlow18 * ((fSlow17 * fRec12[2]) + (fSlow15 * fRec12[1]))));
            output0[i] = (FAUSTFLOAT)((iSlow24)?(fSlow18 * (fRec12[2] + (fRec12[0] + (2 * fRec12[1])))):fRec0[0]);
            // post processing
            fRec12[2] = fRec12[1]; fRec12[1] = fRec12[0];
            fRec13[2] = fRec13[1]; fRec13[1] = fRec13[0];
            fRec14[1] = fRec14[0];
            fVec10[1] = fVec10[0];
            fRec15[1] = fRec15[0];
            fVec9[1] = fVec9[0];
            fRec0[2] = fRec0[1]; fRec0[1] = fRec0[0];
            fVec8[2] = fVec8[1]; fVec8[1] = fVec8[0];
            fRec2[1] = fRec2[0];
            fVec7[1] = fVec7[0];
            fRec3[2] = fRec3[1]; fRec3[1] = fRec3[0];
            fVec6[2] = fVec6[1]; fVec6[1] = fVec6[0];
            fRec8[2] = fRec8[1]; fRec8[1] = fRec8[0];
            fRec9[2] = fRec9[1]; fRec9[1] = fRec9[0];
            fRec10[1] = fRec10[0];
            fVec5[1] = fVec5[0];
            fRec11[1] = fRec11[0];
            fVec4[1] = fVec4[0];
            fRec6[1] = fRec6[0];
            fVec3[1] = fVec3[0];
            fRec7[1] = fRec7[0];
            fVec2[1] = fVec2[0];
            fRec5[1] = fRec5[0];
            IOTA = IOTA+1;
            fRec4[1] = fRec4[0];
            fRec1[1] = fRec1[0];
            iVec0[1] = iVec0[0];
      }
}

static struct RegisterParams { RegisterParams(); } RegisterParams;
RegisterParams::RegisterParams()
{
      registerVar("distortion1.low_highpass.on_off","low highpass","B","",&fcheckbox1, 0.0, 0.0, 1.0, 1.0);
      registerVar("distortion1.resonator.on_off","resonat","B","",&fcheckbox0, 0.0, 0.0, 1.0, 1.0);
      registerVar("distortion1.low_highcutoff.on_off","low highcutoff","B","",&fcheckbox2, 0.0, 0.0, 1.0, 1.0);
      registerVar("distortion1.low_highpass.high_freq","high freq","S","",&fentry1, 1.3e+02, 2e+01, 7.04e+03, 1e+01);
      registerVar("distortion1.low_highpass.low_freq","low freq","S","",&fentry0, 5e+03, 2e+01, 1.2e+04, 1e+01);
      registerVar("distortion1.drive","","S","",&fslider6, 0.64, 0.0, 1.0, 0.01);
      registerVar("distortion1.level","","S","",&fslider5, 0.01, 0.0, 0.5, 0.01);
      registerVar("distortion1.low_highcutoff.low_freq","low freq","S","low-freq cutoff Hz",&fslider4, 1.3e+02, 2e+01, 1e+03, 1e+01);
      registerVar("distortion1.low_highcutoff.high_freq","high freq","S","high-freq cutoff Hz",&fslider3, 5e+03, 1e+03, 1.2e+04, 1e+01);
      registerVar("distortion1.vibrato","","S","",&fslider2, 1.0, 0.0, 1.0, 0.01);
      registerVar("distortion1.trigger","","S","",&fslider1, 0.12, 0.0, 1.0, 0.01);
      registerVar("distortion1.gain","","S","",&fslider0, 2.0, -1e+01, 1e+01, 0.1);
      registerInit("distortion1", init);
}

} // end namespace distortion1

Generated by  Doxygen 1.6.0   Back to index