// generated from file '../src/plugins/mbchor.dsp' by dsp2cc:
// Code generated with Faust 0.9.65 (http://faust.grame.fr)

#include "gx_faust_support.h"
#include "gx_plugin.h"

namespace pluginlib {
namespace mbchor {

class Dsp: public PluginDef {
private:
	int fSamplingFreq;
	class SIG0 {
	  private:
		int 	fSamplingFreq;
		int 	iRec9[2];
	  public:
		int getNumInputs() 	{ return 0; }
		int getNumOutputs() 	{ return 1; }
		void init(int samplingFreq) {
			fSamplingFreq = samplingFreq;
			for (int i=0; i<2; i++) iRec9[i] = 0;
		}
		void fill (int count, double output[]) {
			for (int i=0; i<count; i++) {
				iRec9[0] = (1 + iRec9[1]);
				output[i] = sin((9.587379924285257e-05 * (iRec9[0] - 1)));
				// post processing
				iRec9[1] = iRec9[0];
			}
		}
	};
			int 	iConst0;
	double 	fConst1;
	FAUSTFLOAT 	fslider0;
	double 	fConst2;
	FAUSTFLOAT 	fslider1;
	FAUSTFLOAT 	fslider2;
	FAUSTFLOAT 	fslider3;
	double 	fVec0[2];
	double 	fRec8[2];
	double 	fRec7[3];
	double 	fRec6[3];
	double 	fRec5[3];
	double 	fRec4[3];
	int 	IOTA;
	double 	fVec1[65536];
	static double 	ftbl0[65536];
	FAUSTFLOAT 	fslider4;
	double 	fConst3;
	double 	fRec10[2];
	FAUSTFLOAT 	fslider5;
	FAUSTFLOAT 	fslider6;
	double 	fRec11[2];
	double 	fConst4;
	FAUSTFLOAT 	fslider7;
	double 	fRec0[2];
	int 	iRec1[2];
	double 	fRec2[2];
	FAUSTFLOAT 	fbargraph0;
	double 	fRec21[2];
	double 	fRec20[3];
	double 	fVec2[2];
	double 	fRec19[2];
	double 	fRec18[3];
	double 	fRec17[3];
	double 	fRec16[3];
	double 	fVec3[65536];
	FAUSTFLOAT 	fslider8;
	double 	fRec22[2];
	FAUSTFLOAT 	fslider9;
	FAUSTFLOAT 	fslider10;
	double 	fRec23[2];
	FAUSTFLOAT 	fslider11;
	double 	fRec12[2];
	int 	iRec13[2];
	double 	fRec14[2];
	FAUSTFLOAT 	fbargraph1;
	double 	fRec32[2];
	double 	fRec31[3];
	double 	fVec4[2];
	double 	fRec30[2];
	double 	fRec29[3];
	double 	fRec28[3];
	double 	fVec5[65536];
	FAUSTFLOAT 	fslider12;
	double 	fRec33[2];
	FAUSTFLOAT 	fslider13;
	FAUSTFLOAT 	fslider14;
	double 	fRec34[2];
	FAUSTFLOAT 	fslider15;
	double 	fRec24[2];
	int 	iRec25[2];
	double 	fRec26[2];
	FAUSTFLOAT 	fbargraph2;
	double 	fRec42[2];
	double 	fRec41[3];
	double 	fVec6[2];
	double 	fRec40[2];
	double 	fRec39[3];
	double 	fVec7[65536];
	FAUSTFLOAT 	fslider16;
	double 	fRec43[2];
	FAUSTFLOAT 	fslider17;
	FAUSTFLOAT 	fslider18;
	double 	fRec44[2];
	FAUSTFLOAT 	fslider19;
	double 	fRec35[2];
	int 	iRec36[2];
	double 	fRec37[2];
	FAUSTFLOAT 	fbargraph3;
	double 	fRec50[2];
	double 	fRec49[3];
	double 	fVec8[65536];
	FAUSTFLOAT 	fslider20;
	double 	fRec51[2];
	FAUSTFLOAT 	fslider21;
	FAUSTFLOAT 	fslider22;
	double 	fRec52[2];
	FAUSTFLOAT 	fslider23;
	double 	fRec45[2];
	int 	iRec46[2];
	double 	fRec47[2];
	FAUSTFLOAT 	fbargraph4;
	void clear_state_f();
	int load_ui_f(const UiBuilder& b, int form);
	void init(unsigned int samplingFreq);
	void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
	int register_par(const ParamReg& reg);

	static void clear_state_f_static(PluginDef*);
	static int load_ui_f_static(const UiBuilder& b, int form);
	static void init_static(unsigned int samplingFreq, PluginDef*);
	static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef*);
	static int register_params_static(const ParamReg& reg);
	static void del_instance(PluginDef *p);
public:
	Dsp();
	~Dsp();
};


double Dsp::ftbl0[65536];

Dsp::Dsp()
	: PluginDef() {
	version = PLUGINDEF_VERSION;
	flags = 0;
	id = "mbchor";
	name = N_("MultiBand Chorus");
	groups = 0;
	description = N_("Multi Band Chorus"); // description (tooltip)
	category = N_("Modulation");       // category
	shortname = N_("MB Chorus");     // shortname
	mono_audio = compute_static;
	stereo_audio = 0;
	set_samplerate = init_static;
	activate_plugin = 0;
	register_params = register_params_static;
	load_ui = load_ui_f_static;
	clear_state = clear_state_f_static;
	delete_instance = del_instance;
}

Dsp::~Dsp() {
}

inline void Dsp::clear_state_f()
{
	for (int i=0; i<2; i++) fVec0[i] = 0;
	for (int i=0; i<2; i++) fRec8[i] = 0;
	for (int i=0; i<3; i++) fRec7[i] = 0;
	for (int i=0; i<3; i++) fRec6[i] = 0;
	for (int i=0; i<3; i++) fRec5[i] = 0;
	for (int i=0; i<3; i++) fRec4[i] = 0;
	for (int i=0; i<65536; i++) fVec1[i] = 0;
	for (int i=0; i<2; i++) fRec10[i] = 0;
	for (int i=0; i<2; i++) fRec11[i] = 0;
	for (int i=0; i<2; i++) fRec0[i] = 0;
	for (int i=0; i<2; i++) iRec1[i] = 0;
	for (int i=0; i<2; i++) fRec2[i] = 0;
	for (int i=0; i<2; i++) fRec21[i] = 0;
	for (int i=0; i<3; i++) fRec20[i] = 0;
	for (int i=0; i<2; i++) fVec2[i] = 0;
	for (int i=0; i<2; i++) fRec19[i] = 0;
	for (int i=0; i<3; i++) fRec18[i] = 0;
	for (int i=0; i<3; i++) fRec17[i] = 0;
	for (int i=0; i<3; i++) fRec16[i] = 0;
	for (int i=0; i<65536; i++) fVec3[i] = 0;
	for (int i=0; i<2; i++) fRec22[i] = 0;
	for (int i=0; i<2; i++) fRec23[i] = 0;
	for (int i=0; i<2; i++) fRec12[i] = 0;
	for (int i=0; i<2; i++) iRec13[i] = 0;
	for (int i=0; i<2; i++) fRec14[i] = 0;
	for (int i=0; i<2; i++) fRec32[i] = 0;
	for (int i=0; i<3; i++) fRec31[i] = 0;
	for (int i=0; i<2; i++) fVec4[i] = 0;
	for (int i=0; i<2; i++) fRec30[i] = 0;
	for (int i=0; i<3; i++) fRec29[i] = 0;
	for (int i=0; i<3; i++) fRec28[i] = 0;
	for (int i=0; i<65536; i++) fVec5[i] = 0;
	for (int i=0; i<2; i++) fRec33[i] = 0;
	for (int i=0; i<2; i++) fRec34[i] = 0;
	for (int i=0; i<2; i++) fRec24[i] = 0;
	for (int i=0; i<2; i++) iRec25[i] = 0;
	for (int i=0; i<2; i++) fRec26[i] = 0;
	for (int i=0; i<2; i++) fRec42[i] = 0;
	for (int i=0; i<3; i++) fRec41[i] = 0;
	for (int i=0; i<2; i++) fVec6[i] = 0;
	for (int i=0; i<2; i++) fRec40[i] = 0;
	for (int i=0; i<3; i++) fRec39[i] = 0;
	for (int i=0; i<65536; i++) fVec7[i] = 0;
	for (int i=0; i<2; i++) fRec43[i] = 0;
	for (int i=0; i<2; i++) fRec44[i] = 0;
	for (int i=0; i<2; i++) fRec35[i] = 0;
	for (int i=0; i<2; i++) iRec36[i] = 0;
	for (int i=0; i<2; i++) fRec37[i] = 0;
	for (int i=0; i<2; i++) fRec50[i] = 0;
	for (int i=0; i<3; i++) fRec49[i] = 0;
	for (int i=0; i<65536; i++) fVec8[i] = 0;
	for (int i=0; i<2; i++) fRec51[i] = 0;
	for (int i=0; i<2; i++) fRec52[i] = 0;
	for (int i=0; i<2; i++) fRec45[i] = 0;
	for (int i=0; i<2; i++) iRec46[i] = 0;
	for (int i=0; i<2; i++) fRec47[i] = 0;
}

void Dsp::clear_state_f_static(PluginDef *p)
{
	static_cast<Dsp*>(p)->clear_state_f();
}

inline void Dsp::init(unsigned int samplingFreq)
{
	SIG0 sig0;
	sig0.init(samplingFreq);
	sig0.fill(65536,ftbl0);
	fSamplingFreq = samplingFreq;
	iConst0 = min(192000, max(1, fSamplingFreq));
	fConst1 = (1.0 / double(iConst0));
	fConst2 = (3.141592653589793 / double(iConst0));
	IOTA = 0;
	fConst3 = (0.016666666666666666 / double(iConst0));
	fConst4 = (0.5 * iConst0);
	clear_state_f();
}

void Dsp::init_static(unsigned int samplingFreq, PluginDef *p)
{
	static_cast<Dsp*>(p)->init(samplingFreq);
}

void always_inline Dsp::compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0)
{
	double 	fSlow0 = tan((fConst2 * double(fslider0)));
	double 	fSlow1 = (1.0 / faustpower<2>(fSlow0));
	double 	fSlow2 = (2 * (1 - fSlow1));
	double 	fSlow3 = (1.0 / fSlow0);
	double 	fSlow4 = (1 + ((fSlow3 - 1.0) / fSlow0));
	double 	fSlow5 = (1.0 / (1 + ((1.0 + fSlow3) / fSlow0)));
	double 	fSlow6 = tan((fConst2 * double(fslider1)));
	double 	fSlow7 = (1.0 / faustpower<2>(fSlow6));
	double 	fSlow8 = (2 * (1 - fSlow7));
	double 	fSlow9 = (1.0 / fSlow6);
	double 	fSlow10 = (1 + ((fSlow9 - 1.0) / fSlow6));
	double 	fSlow11 = (1.0 / (1 + ((1.0 + fSlow9) / fSlow6)));
	double 	fSlow12 = tan((fConst2 * double(fslider2)));
	double 	fSlow13 = (1.0 / faustpower<2>(fSlow12));
	double 	fSlow14 = (2 * (1 - fSlow13));
	double 	fSlow15 = (1.0 / fSlow12);
	double 	fSlow16 = (1 + ((fSlow15 - 1.0) / fSlow12));
	double 	fSlow17 = (1.0 / (1 + ((1.0 + fSlow15) / fSlow12)));
	double 	fSlow18 = tan((fConst2 * double(fslider3)));
	double 	fSlow19 = (1.0 / faustpower<2>(fSlow18));
	double 	fSlow20 = (2 * (1 - fSlow19));
	double 	fSlow21 = (1.0 / fSlow18);
	double 	fSlow22 = (1 + ((fSlow21 - 1.0000000000000004) / fSlow18));
	double 	fSlow23 = (1 + ((1.0000000000000004 + fSlow21) / fSlow18));
	double 	fSlow24 = (1.0 / fSlow23);
	double 	fSlow25 = (0 - fSlow21);
	double 	fSlow26 = (1 + fSlow21);
	double 	fSlow27 = (1.0 / fSlow26);
	double 	fSlow28 = (0 - ((1 - fSlow21) / fSlow26));
	double 	fSlow29 = (2 * (0 - fSlow19));
	double 	fSlow30 = (fConst3 * double(fslider4));
	double 	fSlow31 = (0.1 * double(fslider5));
	double 	fSlow32 = (0.0010000000000000009 * double(fslider6));
	double 	fSlow33 = double(fslider7);
	double 	fSlow34 = (1 + ((fSlow15 - 1.0000000000000004) / fSlow12));
	double 	fSlow35 = (1 + ((fSlow15 + 1.0000000000000004) / fSlow12));
	double 	fSlow36 = (1.0 / fSlow35);
	double 	fSlow37 = (0 - fSlow15);
	double 	fSlow38 = (1.0 / (fSlow12 * fSlow23));
	double 	fSlow39 = (1 + fSlow15);
	double 	fSlow40 = (1.0 / fSlow39);
	double 	fSlow41 = (0 - ((1 - fSlow15) / fSlow39));
	double 	fSlow42 = (2 * (0 - fSlow13));
	double 	fSlow43 = (fConst3 * double(fslider8));
	double 	fSlow44 = (0.1 * double(fslider9));
	double 	fSlow45 = (0.0010000000000000009 * double(fslider10));
	double 	fSlow46 = double(fslider11);
	double 	fSlow47 = (1 + ((fSlow9 - 1.0000000000000004) / fSlow6));
	double 	fSlow48 = (1 + ((fSlow9 + 1.0000000000000004) / fSlow6));
	double 	fSlow49 = (1.0 / fSlow48);
	double 	fSlow50 = (0 - fSlow9);
	double 	fSlow51 = (1.0 / (fSlow6 * fSlow35));
	double 	fSlow52 = (1 + fSlow9);
	double 	fSlow53 = (1.0 / fSlow52);
	double 	fSlow54 = (0 - ((1 - fSlow9) / fSlow52));
	double 	fSlow55 = (2 * (0 - fSlow7));
	double 	fSlow56 = (fConst3 * double(fslider12));
	double 	fSlow57 = (0.1 * double(fslider13));
	double 	fSlow58 = (0.0010000000000000009 * double(fslider14));
	double 	fSlow59 = double(fslider15);
	double 	fSlow60 = (1 + ((fSlow3 - 1.0000000000000004) / fSlow0));
	double 	fSlow61 = (1.0 / (1 + ((fSlow3 + 1.0000000000000004) / fSlow0)));
	double 	fSlow62 = (0 - fSlow3);
	double 	fSlow63 = (1.0 / (fSlow0 * fSlow48));
	double 	fSlow64 = (1 + fSlow3);
	double 	fSlow65 = (1.0 / fSlow64);
	double 	fSlow66 = (0 - ((1 - fSlow3) / fSlow64));
	double 	fSlow67 = (2 * (0 - fSlow1));
	double 	fSlow68 = (fConst3 * double(fslider16));
	double 	fSlow69 = (0.1 * double(fslider17));
	double 	fSlow70 = (0.0010000000000000009 * double(fslider18));
	double 	fSlow71 = double(fslider19);
	double 	fSlow72 = (fConst3 * double(fslider20));
	double 	fSlow73 = (0.1 * double(fslider21));
	double 	fSlow74 = (0.0010000000000000009 * double(fslider22));
	double 	fSlow75 = double(fslider23);
	for (int i=0; i<count; i++) {
		double fTemp0 = (fSlow2 * fRec4[1]);
		double fTemp1 = (fSlow8 * fRec5[1]);
		double fTemp2 = (fSlow14 * fRec6[1]);
		double fTemp3 = (double)input0[i];
		fVec0[0] = fTemp3;
		fRec8[0] = ((fSlow28 * fRec8[1]) + (fSlow27 * ((fSlow21 * fVec0[0]) + (fSlow25 * fVec0[1]))));
		fRec7[0] = (fRec8[0] - (fSlow24 * ((fSlow22 * fRec7[2]) + (fSlow20 * fRec7[1]))));
		fRec6[0] = ((fSlow24 * (((fSlow19 * fRec7[0]) + (fSlow29 * fRec7[1])) + (fSlow19 * fRec7[2]))) - (fSlow17 * ((fSlow16 * fRec6[2]) + fTemp2)));
		fRec5[0] = ((fRec6[2] + (fSlow17 * (fTemp2 + (fSlow16 * fRec6[0])))) - (fSlow11 * ((fSlow10 * fRec5[2]) + fTemp1)));
		fRec4[0] = ((fRec5[2] + (fSlow11 * (fTemp1 + (fSlow10 * fRec5[0])))) - (fSlow5 * ((fSlow4 * fRec4[2]) + fTemp0)));
		double fTemp4 = (fRec4[2] + (fSlow5 * (fTemp0 + (fSlow4 * fRec4[0]))));
		fVec1[IOTA&65535] = fTemp4;
		double fTemp5 = (fSlow30 + fRec10[1]);
		fRec10[0] = (fTemp5 - floor(fTemp5));
		double fTemp6 = (65536 * (fRec10[0] - floor(fRec10[0])));
		double fTemp7 = floor(fTemp6);
		int iTemp8 = int(fTemp7);
		fRec11[0] = (fSlow32 + (0.999 * fRec11[1]));
		double fTemp9 = (fConst4 * (fRec11[0] * (1 + (fSlow31 * ((((1 + fTemp7) - fTemp6) * ftbl0[(iTemp8 & 65535)]) + ((fTemp6 - fTemp7) * ftbl0[((1 + iTemp8) & 65535)]))))));
		int iTemp10 = int(fTemp9);
		int iTemp11 = (1 + iTemp10);
		double fTemp12 = (fSlow33 * (fVec1[IOTA&65535] + (fSlow33 * ((fVec1[(IOTA-int((iTemp10 & 65535)))&65535] * (iTemp11 - fTemp9)) + ((fTemp9 - iTemp10) * fVec1[(IOTA-int((int(iTemp11) & 65535)))&65535])))));
		double 	fRec3 = max(fConst1, fabs(fTemp12));
		int iTemp13 = int((iRec1[1] < 4096));
		fRec0[0] = ((iTemp13)?max(fRec0[1], fRec3):fRec3);
		iRec1[0] = ((iTemp13)?(1 + iRec1[1]):1);
		fRec2[0] = ((iTemp13)?fRec2[1]:fRec0[1]);
		fbargraph0 = fRec2[0];
		double fTemp14 = (fSlow2 * fRec16[1]);
		double fTemp15 = (fSlow8 * fRec17[1]);
		fRec21[0] = ((fSlow28 * fRec21[1]) + (fSlow27 * (fVec0[0] + fVec0[1])));
		fRec20[0] = (fRec21[0] - (fSlow24 * ((fSlow22 * fRec20[2]) + (fSlow20 * fRec20[1]))));
		double fTemp16 = (fRec20[2] + (fRec20[0] + (2 * fRec20[1])));
		double fTemp17 = (fSlow24 * fTemp16);
		fVec2[0] = fTemp17;
		fRec19[0] = ((fSlow41 * fRec19[1]) + (fSlow40 * ((fSlow38 * fTemp16) + (fSlow37 * fVec2[1]))));
		fRec18[0] = (fRec19[0] - (fSlow36 * ((fSlow34 * fRec18[2]) + (fSlow14 * fRec18[1]))));
		fRec17[0] = ((fSlow36 * (((fSlow13 * fRec18[0]) + (fSlow42 * fRec18[1])) + (fSlow13 * fRec18[2]))) - (fSlow11 * ((fSlow10 * fRec17[2]) + fTemp15)));
		fRec16[0] = ((fRec17[2] + (fSlow11 * (fTemp15 + (fSlow10 * fRec17[0])))) - (fSlow5 * ((fSlow4 * fRec16[2]) + fTemp14)));
		double fTemp18 = (fRec16[2] + (fSlow5 * (fTemp14 + (fSlow4 * fRec16[0]))));
		fVec3[IOTA&65535] = fTemp18;
		double fTemp19 = (fSlow43 + fRec22[1]);
		fRec22[0] = (fTemp19 - floor(fTemp19));
		double fTemp20 = (65536 * (fRec22[0] - floor(fRec22[0])));
		double fTemp21 = floor(fTemp20);
		int iTemp22 = int(fTemp21);
		fRec23[0] = (fSlow45 + (0.999 * fRec23[1]));
		double fTemp23 = (fConst4 * (fRec23[0] * (1 + (fSlow44 * ((((1 + fTemp21) - fTemp20) * ftbl0[(iTemp22 & 65535)]) + ((fTemp20 - fTemp21) * ftbl0[((1 + iTemp22) & 65535)]))))));
		int iTemp24 = int(fTemp23);
		int iTemp25 = (1 + iTemp24);
		double fTemp26 = (fSlow46 * (fVec3[IOTA&65535] + (fSlow46 * ((fVec3[(IOTA-int((iTemp24 & 65535)))&65535] * (iTemp25 - fTemp23)) + ((fTemp23 - iTemp24) * fVec3[(IOTA-int((int(iTemp25) & 65535)))&65535])))));
		double 	fRec15 = max(fConst1, fabs(fTemp26));
		int iTemp27 = int((iRec13[1] < 4096));
		fRec12[0] = ((iTemp27)?max(fRec12[1], fRec15):fRec15);
		iRec13[0] = ((iTemp27)?(1 + iRec13[1]):1);
		fRec14[0] = ((iTemp27)?fRec14[1]:fRec12[1]);
		fbargraph1 = fRec14[0];
		double fTemp28 = (fSlow2 * fRec28[1]);
		fRec32[0] = ((fSlow41 * fRec32[1]) + (fSlow40 * (fVec2[0] + fVec2[1])));
		fRec31[0] = (fRec32[0] - (fSlow36 * ((fSlow34 * fRec31[2]) + (fSlow14 * fRec31[1]))));
		double fTemp29 = (fRec31[2] + (fRec31[0] + (2 * fRec31[1])));
		double fTemp30 = (fSlow36 * fTemp29);
		fVec4[0] = fTemp30;
		fRec30[0] = ((fSlow54 * fRec30[1]) + (fSlow53 * ((fSlow51 * fTemp29) + (fSlow50 * fVec4[1]))));
		fRec29[0] = (fRec30[0] - (fSlow49 * ((fSlow47 * fRec29[2]) + (fSlow8 * fRec29[1]))));
		fRec28[0] = ((fSlow49 * (((fSlow7 * fRec29[0]) + (fSlow55 * fRec29[1])) + (fSlow7 * fRec29[2]))) - (fSlow5 * ((fSlow4 * fRec28[2]) + fTemp28)));
		double fTemp31 = (fRec28[2] + (fSlow5 * (fTemp28 + (fSlow4 * fRec28[0]))));
		fVec5[IOTA&65535] = fTemp31;
		double fTemp32 = (fSlow56 + fRec33[1]);
		fRec33[0] = (fTemp32 - floor(fTemp32));
		double fTemp33 = (65536 * (fRec33[0] - floor(fRec33[0])));
		double fTemp34 = floor(fTemp33);
		int iTemp35 = int(fTemp34);
		fRec34[0] = (fSlow58 + (0.999 * fRec34[1]));
		double fTemp36 = (fConst4 * (fRec34[0] * (1 + (fSlow57 * ((((1 + fTemp34) - fTemp33) * ftbl0[(iTemp35 & 65535)]) + ((fTemp33 - fTemp34) * ftbl0[((1 + iTemp35) & 65535)]))))));
		int iTemp37 = int(fTemp36);
		int iTemp38 = (1 + iTemp37);
		double fTemp39 = (fSlow59 * (fVec5[IOTA&65535] + (fSlow59 * ((fVec5[(IOTA-int((iTemp37 & 65535)))&65535] * (iTemp38 - fTemp36)) + ((fTemp36 - iTemp37) * fVec5[(IOTA-int((int(iTemp38) & 65535)))&65535])))));
		double 	fRec27 = max(fConst1, fabs(fTemp39));
		int iTemp40 = int((iRec25[1] < 4096));
		fRec24[0] = ((iTemp40)?max(fRec24[1], fRec27):fRec27);
		iRec25[0] = ((iTemp40)?(1 + iRec25[1]):1);
		fRec26[0] = ((iTemp40)?fRec26[1]:fRec24[1]);
		fbargraph2 = fRec26[0];
		fRec42[0] = ((fSlow54 * fRec42[1]) + (fSlow53 * (fVec4[0] + fVec4[1])));
		fRec41[0] = (fRec42[0] - (fSlow49 * ((fSlow47 * fRec41[2]) + (fSlow8 * fRec41[1]))));
		double fTemp41 = (fRec41[2] + (fRec41[0] + (2 * fRec41[1])));
		double fTemp42 = (fSlow49 * fTemp41);
		fVec6[0] = fTemp42;
		fRec40[0] = ((fSlow66 * fRec40[1]) + (fSlow65 * ((fSlow63 * fTemp41) + (fSlow62 * fVec6[1]))));
		fRec39[0] = (fRec40[0] - (fSlow61 * ((fSlow60 * fRec39[2]) + (fSlow2 * fRec39[1]))));
		double fTemp43 = (fSlow61 * (((fSlow1 * fRec39[0]) + (fSlow67 * fRec39[1])) + (fSlow1 * fRec39[2])));
		fVec7[IOTA&65535] = fTemp43;
		double fTemp44 = (fSlow68 + fRec43[1]);
		fRec43[0] = (fTemp44 - floor(fTemp44));
		double fTemp45 = (65536 * (fRec43[0] - floor(fRec43[0])));
		double fTemp46 = floor(fTemp45);
		int iTemp47 = int(fTemp46);
		fRec44[0] = (fSlow70 + (0.999 * fRec44[1]));
		double fTemp48 = (fConst4 * (fRec44[0] * (1 + (fSlow69 * ((((1 + fTemp46) - fTemp45) * ftbl0[(iTemp47 & 65535)]) + ((fTemp45 - fTemp46) * ftbl0[((1 + iTemp47) & 65535)]))))));
		int iTemp49 = int(fTemp48);
		int iTemp50 = (1 + iTemp49);
		double fTemp51 = (fSlow71 * (fVec7[IOTA&65535] + (fSlow71 * ((fVec7[(IOTA-int((iTemp49 & 65535)))&65535] * (iTemp50 - fTemp48)) + ((fTemp48 - iTemp49) * fVec7[(IOTA-int((int(iTemp50) & 65535)))&65535])))));
		double 	fRec38 = max(fConst1, fabs(fTemp51));
		int iTemp52 = int((iRec36[1] < 4096));
		fRec35[0] = ((iTemp52)?max(fRec35[1], fRec38):fRec38);
		iRec36[0] = ((iTemp52)?(1 + iRec36[1]):1);
		fRec37[0] = ((iTemp52)?fRec37[1]:fRec35[1]);
		fbargraph3 = fRec37[0];
		fRec50[0] = ((fSlow66 * fRec50[1]) + (fSlow65 * (fVec6[0] + fVec6[1])));
		fRec49[0] = (fRec50[0] - (fSlow61 * ((fSlow60 * fRec49[2]) + (fSlow2 * fRec49[1]))));
		double fTemp53 = (fSlow61 * (fRec49[2] + (fRec49[0] + (2 * fRec49[1]))));
		fVec8[IOTA&65535] = fTemp53;
		double fTemp54 = (fSlow72 + fRec51[1]);
		fRec51[0] = (fTemp54 - floor(fTemp54));
		double fTemp55 = (65536 * (fRec51[0] - floor(fRec51[0])));
		double fTemp56 = floor(fTemp55);
		int iTemp57 = int(fTemp56);
		fRec52[0] = (fSlow74 + (0.999 * fRec52[1]));
		double fTemp58 = (fConst4 * (fRec52[0] * (1 + (fSlow73 * ((((1 + fTemp56) - fTemp55) * ftbl0[(iTemp57 & 65535)]) + ((fTemp55 - fTemp56) * ftbl0[((1 + iTemp57) & 65535)]))))));
		int iTemp59 = int(fTemp58);
		int iTemp60 = (1 + iTemp59);
		double fTemp61 = (fSlow75 * (fVec8[IOTA&65535] + (fSlow75 * ((fVec8[(IOTA-int((iTemp59 & 65535)))&65535] * (iTemp60 - fTemp58)) + ((fTemp58 - iTemp59) * fVec8[(IOTA-int((int(iTemp60) & 65535)))&65535])))));
		double 	fRec48 = max(fConst1, fabs(fTemp61));
		int iTemp62 = int((iRec46[1] < 4096));
		fRec45[0] = ((iTemp62)?max(fRec45[1], fRec48):fRec48);
		iRec46[0] = ((iTemp62)?(1 + iRec46[1]):1);
		fRec47[0] = ((iTemp62)?fRec47[1]:fRec45[1]);
		fbargraph4 = fRec47[0];
		output0[i] = (FAUSTFLOAT)(fTemp61 + (fTemp51 + (fTemp39 + (fTemp26 + (fVec0[0] + fTemp12)))));
		// post processing
		fRec47[1] = fRec47[0];
		iRec46[1] = iRec46[0];
		fRec45[1] = fRec45[0];
		fRec52[1] = fRec52[0];
		fRec51[1] = fRec51[0];
		fRec49[2] = fRec49[1]; fRec49[1] = fRec49[0];
		fRec50[1] = fRec50[0];
		fRec37[1] = fRec37[0];
		iRec36[1] = iRec36[0];
		fRec35[1] = fRec35[0];
		fRec44[1] = fRec44[0];
		fRec43[1] = fRec43[0];
		fRec39[2] = fRec39[1]; fRec39[1] = fRec39[0];
		fRec40[1] = fRec40[0];
		fVec6[1] = fVec6[0];
		fRec41[2] = fRec41[1]; fRec41[1] = fRec41[0];
		fRec42[1] = fRec42[0];
		fRec26[1] = fRec26[0];
		iRec25[1] = iRec25[0];
		fRec24[1] = fRec24[0];
		fRec34[1] = fRec34[0];
		fRec33[1] = fRec33[0];
		fRec28[2] = fRec28[1]; fRec28[1] = fRec28[0];
		fRec29[2] = fRec29[1]; fRec29[1] = fRec29[0];
		fRec30[1] = fRec30[0];
		fVec4[1] = fVec4[0];
		fRec31[2] = fRec31[1]; fRec31[1] = fRec31[0];
		fRec32[1] = fRec32[0];
		fRec14[1] = fRec14[0];
		iRec13[1] = iRec13[0];
		fRec12[1] = fRec12[0];
		fRec23[1] = fRec23[0];
		fRec22[1] = fRec22[0];
		fRec16[2] = fRec16[1]; fRec16[1] = fRec16[0];
		fRec17[2] = fRec17[1]; fRec17[1] = fRec17[0];
		fRec18[2] = fRec18[1]; fRec18[1] = fRec18[0];
		fRec19[1] = fRec19[0];
		fVec2[1] = fVec2[0];
		fRec20[2] = fRec20[1]; fRec20[1] = fRec20[0];
		fRec21[1] = fRec21[0];
		fRec2[1] = fRec2[0];
		iRec1[1] = iRec1[0];
		fRec0[1] = fRec0[0];
		fRec11[1] = fRec11[0];
		fRec10[1] = fRec10[0];
		IOTA = IOTA+1;
		fRec4[2] = fRec4[1]; fRec4[1] = fRec4[0];
		fRec5[2] = fRec5[1]; fRec5[1] = fRec5[0];
		fRec6[2] = fRec6[1]; fRec6[1] = fRec6[0];
		fRec7[2] = fRec7[1]; fRec7[1] = fRec7[0];
		fRec8[1] = fRec8[0];
		fVec0[1] = fVec0[0];
	}
}

void __rt_func Dsp::compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef *p)
{
	static_cast<Dsp*>(p)->compute(count, input0, output0);
}

int Dsp::register_par(const ParamReg& reg)
{
	reg.registerVar("mbchor.crossover_b1_b2",N_("Crossover B1-B2 (hz)"),"SL",N_("Crossover bandpass frequency"),&fslider0, 8e+01, 2e+01, 2e+04, 1.08);
	reg.registerVar("mbchor.crossover_b2_b3",N_("Crossover B2-B3 (hz)"),"SL",N_("Crossover bandpass frequency"),&fslider1, 2.1e+02, 2e+01, 2e+04, 1.08);
	reg.registerVar("mbchor.crossover_b3_b4",N_("Crossover B3-B4 (hz)"),"SL",N_("Crossover bandpass frequency"),&fslider2, 1.7e+03, 2e+01, 2e+04, 1.08);
	reg.registerVar("mbchor.crossover_b4_b5",N_("Crossover B4-B5 (hz)"),"SL",N_("Crossover bandpass frequency"),&fslider3, 5e+03, 2e+01, 2e+04, 1.08);
	reg.registerVar("mbchor.delay1","","S","",&fslider22, 0.02, 0.0, 0.2, 0.01);
	reg.registerVar("mbchor.delay2","","S","",&fslider18, 0.04, 0.0, 0.2, 0.01);
	reg.registerVar("mbchor.delay3","","S","",&fslider14, 0.06, 0.0, 0.2, 0.01);
	reg.registerVar("mbchor.delay4","","S","",&fslider10, 0.08, 0.0, 0.2, 0.01);
	reg.registerVar("mbchor.delay5","","S","",&fslider6, 0.1, 0.0, 0.2, 0.01);
	reg.registerVar("mbchor.depth1","","S","",&fslider21, 0.02, 0.01, 1.0, 0.01);
	reg.registerVar("mbchor.depth2","","S","",&fslider17, 0.04, 0.01, 1.0, 0.01);
	reg.registerVar("mbchor.depth3","","S","",&fslider13, 0.06, 0.01, 1.0, 0.01);
	reg.registerVar("mbchor.depth4","","S","",&fslider9, 0.08, 0.01, 1.0, 0.01);
	reg.registerVar("mbchor.depth5","","S","",&fslider5, 0.1, 0.01, 1.0, 0.01);
	reg.registerVar("mbchor.freq1","","S",N_("Beats per Minute"),&fslider20, 3e+01, 24.0, 3.6e+02, 1.0);
	reg.registerVar("mbchor.freq2","","S",N_("Beats per Minute"),&fslider16, 6e+01, 24.0, 3.6e+02, 1.0);
	reg.registerVar("mbchor.freq3","","S",N_("Beats per Minute"),&fslider12, 9e+01, 24.0, 3.6e+02, 1.0);
	reg.registerVar("mbchor.freq4","","S",N_("Beats per Minute"),&fslider8, 1.2e+02, 24.0, 3.6e+02, 1.0);
	reg.registerVar("mbchor.freq5","","S",N_("Beats per Minute"),&fslider4, 1.5e+02, 24.0, 3.6e+02, 1.0);
	reg.registerVar("mbchor.level1","","S","",&fslider23, 0.5, 0.0, 1.0, 0.01);
	reg.registerVar("mbchor.level2","","S","",&fslider19, 0.5, 0.0, 1.0, 0.01);
	reg.registerVar("mbchor.level3","","S","",&fslider15, 0.5, 0.0, 1.0, 0.01);
	reg.registerVar("mbchor.level4","","S","",&fslider11, 0.5, 0.0, 1.0, 0.01);
	reg.registerVar("mbchor.level5","","S","",&fslider7, 0.5, 0.0, 1.0, 0.01);
	reg.registerNonMidiFloatVar("mbchor.v1",&fbargraph4, false, true, -70.0, -70.0, 4.0, 0.00001);
	reg.registerNonMidiFloatVar("mbchor.v2",&fbargraph3, false, true, -70.0, -70.0, 4.0, 0.00001);
	reg.registerNonMidiFloatVar("mbchor.v3",&fbargraph2, false, true, -70.0, -70.0, 4.0, 0.00001);
	reg.registerNonMidiFloatVar("mbchor.v4",&fbargraph1, false, true, -70.0, -70.0, 4.0, 0.00001);
	reg.registerNonMidiFloatVar("mbchor.v5",&fbargraph0, false, true, -70.0, -70.0, 4.0, 0.00001);
	return 0;
}

int Dsp::register_params_static(const ParamReg& reg)
{
	return static_cast<Dsp*>(reg.plugin)->register_par(reg);
}

inline int Dsp::load_ui_f(const UiBuilder& b, int form)
{
    if (form & UI_FORM_STACK) {
#define PARAM(p) ("mbchor" "." p)

b.openHorizontalhideBox("");
b.closeBox();

b.openHorizontalBox("");
b.openVerticalBox("");

b.openTabBox("");

b.openHorizontalBox(N_("Band 1"));
b.openVerticalBox("");
b.openpaintampBox("");
b.openHorizontalBox("");
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("level1"), N_("Level"));
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("freq1"), N_("BPM"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("delay1"), N_("Delay"));
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("depth1"), N_("Depth"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("crossover_b1_b2"), N_("Low Shelf (Hz)"));
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();

b.openHorizontalBox(N_("Band 2"));
b.openVerticalBox("");
b.openpaintampBox("");
b.openHorizontalBox("");
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("level2"), N_("Level"));
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("freq2"), N_("BPM"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("delay2"), N_("Delay"));
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("depth2"), N_("Depth"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("crossover_b1_b2"), N_("Low (Hz)"));
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("crossover_b2_b3"), N_("High (hz)"));
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();

b.openHorizontalBox(N_("Band 3"));
b.openVerticalBox("");
b.openpaintampBox("");
b.openHorizontalBox("");
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("level3"), N_("Level"));
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("freq3"), N_("BPM"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("delay3"), N_("Delay"));
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("depth3"), N_("Depth"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("crossover_b2_b3"), N_("Low (Hz)"));
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("crossover_b3_b4"), N_("High (hz)"));
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();

b.openHorizontalBox(N_("Band 4"));
b.openVerticalBox("");
b.openpaintampBox("");
b.openHorizontalBox("");
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("level4"), N_("Level"));
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("freq4"), N_("BPM"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("delay4"), N_("Delay"));
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("depth4"), N_("Depth"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("crossover_b3_b4"), N_("Low (Hz)"));
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("crossover_b4_b5"), N_("High (hz)"));
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();

b.openHorizontalBox(N_("Band 5"));
b.openVerticalBox("");
b.openpaintampBox("");
b.openHorizontalBox("");
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("level5"), N_("Level"));
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("freq5"), N_("BPM"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("delay5"), N_("Delay"));
b.set_next_flags(UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("depth5"), N_("Depth"));
b.closeBox();
b.openVerticalBox("");
b.set_next_flags(UI_NUM_SHOW_ALWAYS|UI_NUM_RIGHT);
b.create_small_rackknob(PARAM("crossover_b4_b5"), N_("High Shelf (Hz)"));
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();
b.closeBox();

b.closeBox();
b.closeBox();
b.openVerticalBox2("Analyze");
b.create_simple_meter(PARAM("v1"));
b.create_simple_meter(PARAM("v2"));
b.create_simple_meter(PARAM("v3"));
b.create_simple_meter(PARAM("v4"));
b.create_simple_meter(PARAM("v5"));
b.closeBox();
b.closeBox();

#undef PARAM
        return 0;
    }
	return -1;
}

int Dsp::load_ui_f_static(const UiBuilder& b, int form)
{
	return static_cast<Dsp*>(b.plugin)->load_ui_f(b, form);
}
PluginDef *plugin() {
	return new Dsp();
}

void Dsp::del_instance(PluginDef *p)
{
	delete static_cast<Dsp*>(p);
}

} // end namespace mbchor
} // end namespace pluginlib
