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

FAUSTFLOAT 	fslider0;
double 	fRec0[6];
FAUSTFLOAT 	fslider1;
FAUSTFLOAT 	fslider2;
double 	fConst0;
double 	fConst1;
double 	fConst2;
FAUSTFLOAT 	fslider3;
double 	fRec4[2];
double 	fConst3;
double 	fConst4;
double 	fConst5;
FAUSTFLOAT 	fslider4;
double 	fRec8[2];
FAUSTFLOAT 	fslider5;
double 	fRec12[2];
double 	fConst6;
double 	fConst7;
double 	fConst8;
double 	fVec0[2];
double 	fConst9;
double 	fRec13[2];
double 	fRec11[2];
double 	fConst10;
double 	fConst11;
double 	fRec10[2];
double 	fConst12;
double 	fRec9[2];
double 	fConst13;
double 	fConst14;
double 	fConst15;
double 	fVec1[2];
double 	fConst16;
double 	fRec14[2];
double 	fRec7[2];
double 	fRec6[2];
double 	fRec5[2];
double 	fConst17;
double 	fConst18;
double 	fConst19;
double 	fVec2[2];
double 	fConst20;
double 	fRec15[2];
double 	fRec3[2];
double 	fRec2[2];
double 	fRec1[6];
double 	fRec16[6];
double 	fVec3[2];
double 	fRec26[2];
double 	fRec25[2];
double 	fRec24[2];
double 	fRec23[2];
double 	fVec4[2];
double 	fRec27[2];
double 	fRec22[2];
double 	fRec21[2];
double 	fRec20[2];
double 	fVec5[2];
double 	fRec28[2];
double 	fRec19[2];
double 	fRec18[2];
double 	fRec17[6];
int	fSamplingFreq;

void init(int samplingFreq)
{
	fSamplingFreq = samplingFreq;
	for (int i=0; i<6; i++) fRec0[i] = 0;
	fConst0 = (1.0 / tan((97.38937226128358 / fSamplingFreq)));
	fConst1 = (1 + fConst0);
	fConst2 = (0 - ((1 - fConst0) / fConst1));
	for (int i=0; i<2; i++) fRec4[i] = 0;
	fConst3 = (1.0 / tan((20517.741620594938 / fSamplingFreq)));
	fConst4 = (1 + fConst3);
	fConst5 = (0 - ((1 - fConst3) / fConst4));
	for (int i=0; i<2; i++) fRec8[i] = 0;
	for (int i=0; i<2; i++) fRec12[i] = 0;
	fConst6 = (1.0 / tan((270.1769682087222 / fSamplingFreq)));
	fConst7 = (1 + fConst6);
	fConst8 = (0 - ((1 - fConst6) / fConst7));
	for (int i=0; i<2; i++) fVec0[i] = 0;
	fConst9 = (0.027 / fConst7);
	for (int i=0; i<2; i++) fRec13[i] = 0;
	for (int i=0; i<2; i++) fRec11[i] = 0;
	fConst10 = (0 - fConst0);
	fConst11 = (0.025 / fConst1);
	for (int i=0; i<2; i++) fRec10[i] = 0;
	fConst12 = (1.0 / fConst4);
	for (int i=0; i<2; i++) fRec9[i] = 0;
	fConst13 = (1.0 / tan((414.6902302738527 / fSamplingFreq)));
	fConst14 = (1 + fConst13);
	fConst15 = (0 - ((1 - fConst13) / fConst14));
	for (int i=0; i<2; i++) fVec1[i] = 0;
	fConst16 = (0.015 / fConst14);
	for (int i=0; i<2; i++) fRec14[i] = 0;
	for (int i=0; i<2; i++) fRec7[i] = 0;
	for (int i=0; i<2; i++) fRec6[i] = 0;
	for (int i=0; i<2; i++) fRec5[i] = 0;
	fConst17 = (1.0 / tan((609.4689747964198 / fSamplingFreq)));
	fConst18 = (1 + fConst17);
	fConst19 = (0 - ((1 - fConst17) / fConst18));
	for (int i=0; i<2; i++) fVec2[i] = 0;
	fConst20 = (0.0082 / fConst18);
	for (int i=0; i<2; i++) fRec15[i] = 0;
	for (int i=0; i<2; i++) fRec3[i] = 0;
	for (int i=0; i<2; i++) fRec2[i] = 0;
	for (int i=0; i<6; i++) fRec1[i] = 0;
	for (int i=0; i<6; i++) fRec16[i] = 0;
	for (int i=0; i<2; i++) fVec3[i] = 0;
	for (int i=0; i<2; i++) fRec26[i] = 0;
	for (int i=0; i<2; i++) fRec25[i] = 0;
	for (int i=0; i<2; i++) fRec24[i] = 0;
	for (int i=0; i<2; i++) fRec23[i] = 0;
	for (int i=0; i<2; i++) fVec4[i] = 0;
	for (int i=0; i<2; i++) fRec27[i] = 0;
	for (int i=0; i<2; i++) fRec22[i] = 0;
	for (int i=0; i<2; i++) fRec21[i] = 0;
	for (int i=0; i<2; i++) fRec20[i] = 0;
	for (int i=0; i<2; i++) fVec5[i] = 0;
	for (int i=0; i<2; i++) fRec28[i] = 0;
	for (int i=0; i<2; i++) fRec19[i] = 0;
	for (int i=0; i<2; i++) fRec18[i] = 0;
	for (int i=0; i<6; i++) fRec17[i] = 0;
}

void compute(int count, float *input0, float *input1, float *output0, float *output1)
{
	double 	fSlow0 = fslider0;
	double 	fSlow1 = fslider1;
	double 	fSlow2 = (1 - max(0, fSlow1));
	double 	fSlow3 = fslider2;
	double 	fSlow4 = (0.0010000000000000009 * pow(10,(0.05 * fslider3)));
	double 	fSlow5 = (0.0010000000000000009 * pow(10,(0.05 * fslider4)));
	double 	fSlow6 = (0.0010000000000000009 * pow(10,(0.05 * fslider5)));
	double 	fSlow7 = (1 - max(0, (0 - fSlow1)));
	for (int i=0; i<count; i++) {
		double fTemp0 = (double)input0[i];
		fRec0[0] = (fTemp0 - (fSlow0 * fRec0[5]));
		fRec4[0] = (fSlow4 + (0.999 * fRec4[1]));
		fRec8[0] = (fSlow5 + (0.999 * fRec8[1]));
		fRec12[0] = (fSlow6 + (0.999 * fRec12[1]));
		double fTemp1 = (fRec11[1] - 2.5e+02);
		fVec0[0] = fTemp1;
		fRec13[0] = ((fConst9 * (fVec0[0] + fVec0[1])) + (fConst8 * fRec13[1]));
		fRec11[0] = Ftube2(0, (fRec13[0] + (fTemp0 * fRec12[0])));
		fRec10[0] = ((fConst11 * ((fConst10 * fRec11[1]) + (fConst0 * fRec11[0]))) + (fConst2 * fRec10[1]));
		fRec9[0] = ((fConst12 * (fRec10[0] + fRec10[1])) + (fConst5 * fRec9[1]));
		double fTemp2 = (fRec7[1] - 2.5e+02);
		fVec1[0] = fTemp2;
		fRec14[0] = ((fConst16 * (fVec1[0] + fVec1[1])) + (fConst15 * fRec14[1]));
		fRec7[0] = Ftube2(1, (fRec14[0] + (fRec9[0] * fRec8[0])));
		fRec6[0] = ((fConst11 * ((fConst10 * fRec7[1]) + (fConst0 * fRec7[0]))) + (fConst2 * fRec6[1]));
		fRec5[0] = ((fConst12 * (fRec6[0] + fRec6[1])) + (fConst5 * fRec5[1]));
		double fTemp3 = (fRec3[1] - 2.5e+02);
		fVec2[0] = fTemp3;
		fRec15[0] = ((fConst20 * (fVec2[0] + fVec2[1])) + (fConst19 * fRec15[1]));
		fRec3[0] = Ftube2(1, (fRec15[0] + (fRec5[0] * fRec4[0])));
		fRec2[0] = ((fConst11 * ((fConst10 * fRec3[1]) + (fConst0 * fRec3[0]))) + (fConst2 * fRec2[1]));
		fRec1[0] = (fRec2[0] - (fSlow3 * fRec1[5]));
		output0[i] = (FAUSTFLOAT)((fSlow7 * fRec1[0]) + (fSlow2 * fRec0[0]));
		double fTemp4 = (double)input1[i];
		fRec16[0] = (fTemp4 - (fSlow0 * fRec16[5]));
		double fTemp5 = (fRec25[1] - 2.5e+02);
		fVec3[0] = fTemp5;
		fRec26[0] = ((fConst9 * (fVec3[0] + fVec3[1])) + (fConst8 * fRec26[1]));
		fRec25[0] = Ftube2(0, (fRec26[0] + (fTemp4 * fRec12[0])));
		fRec24[0] = ((fConst11 * ((fConst10 * fRec25[1]) + (fConst0 * fRec25[0]))) + (fConst2 * fRec24[1]));
		fRec23[0] = ((fConst12 * (fRec24[0] + fRec24[1])) + (fConst5 * fRec23[1]));
		double fTemp6 = (fRec22[1] - 2.5e+02);
		fVec4[0] = fTemp6;
		fRec27[0] = ((fConst16 * (fVec4[0] + fVec4[1])) + (fConst15 * fRec27[1]));
		fRec22[0] = Ftube2(1, (fRec27[0] + (fRec8[0] * fRec23[0])));
		fRec21[0] = ((fConst11 * ((fConst10 * fRec22[1]) + (fConst0 * fRec22[0]))) + (fConst2 * fRec21[1]));
		fRec20[0] = ((fConst12 * (fRec21[0] + fRec21[1])) + (fConst5 * fRec20[1]));
		double fTemp7 = (fRec19[1] - 2.5e+02);
		fVec5[0] = fTemp7;
		fRec28[0] = ((fConst20 * (fVec5[0] + fVec5[1])) + (fConst19 * fRec28[1]));
		fRec19[0] = Ftube2(1, (fRec28[0] + (fRec4[0] * fRec20[0])));
		fRec18[0] = ((fConst11 * ((fConst10 * fRec19[1]) + (fConst0 * fRec19[0]))) + (fConst2 * fRec18[1]));
		fRec17[0] = (fRec18[0] - (fSlow3 * fRec17[5]));
		output1[i] = (FAUSTFLOAT)((fSlow7 * fRec17[0]) + (fSlow2 * fRec16[0]));
		// post processing
		for (int i=5; i>0; i--) fRec17[i] = fRec17[i-1];
		fRec18[1] = fRec18[0];
		fRec19[1] = fRec19[0];
		fRec28[1] = fRec28[0];
		fVec5[1] = fVec5[0];
		fRec20[1] = fRec20[0];
		fRec21[1] = fRec21[0];
		fRec22[1] = fRec22[0];
		fRec27[1] = fRec27[0];
		fVec4[1] = fVec4[0];
		fRec23[1] = fRec23[0];
		fRec24[1] = fRec24[0];
		fRec25[1] = fRec25[0];
		fRec26[1] = fRec26[0];
		fVec3[1] = fVec3[0];
		for (int i=5; i>0; i--) fRec16[i] = fRec16[i-1];
		for (int i=5; i>0; i--) fRec1[i] = fRec1[i-1];
		fRec2[1] = fRec2[0];
		fRec3[1] = fRec3[0];
		fRec15[1] = fRec15[0];
		fVec2[1] = fVec2[0];
		fRec5[1] = fRec5[0];
		fRec6[1] = fRec6[0];
		fRec7[1] = fRec7[0];
		fRec14[1] = fRec14[0];
		fVec1[1] = fVec1[0];
		fRec9[1] = fRec9[0];
		fRec10[1] = fRec10[0];
		fRec11[1] = fRec11[0];
		fRec13[1] = fRec13[0];
		fVec0[1] = fVec0[0];
		fRec12[1] = fRec12[0];
		fRec8[1] = fRec8[0];
		fRec4[1] = fRec4[0];
		for (int i=5; i>0; i--) fRec0[i] = fRec0[i-1];
	}
}

static struct RegisterParams { RegisterParams(); } RegisterParams;
RegisterParams::RegisterParams()
{
	registerVar("ampmodul.level","","S","",&fslider5, -2e+01, -4e+01, 4.0, 0.1);
	registerVar("ampmodul.amp2.stage1.tube1","","S","",&fslider4, 6.0, -2e+01, 2e+01, 0.1);
	registerVar("ampmodul.amp2.stage2.tube2","","S","",&fslider3, 6.0, -2e+01, 2e+01, 0.1);
	registerVar("ampmodul.feedback","","S","",&fslider2, 0.0, -1.0, 1.0, 0.01);
	registerVar("ampmodul.wet_dry","","S","",&fslider1, 0.0, -1.0, 1.0, 0.1);
	registerVar("ampmodul.feedbac","","S","",&fslider0, 0.0, -1.0, 1.0, 0.01);
	registerInit("ampmodul", init);
}

} // end namespace gx_ampmodul
