//----------------------------------------------------------
// name: "bs"
//
// Code generated with Faust 2.81.0 (https://faust.grame.fr)
//----------------------------------------------------------

/* link with  */
#include <math.h>
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif 


#ifndef FAUSTCLASS 
#define FAUSTCLASS mydsp
#endif

class mydsp : public dsp {
  private:
	// Recursion delay fVeeec0 is of type kSingleDelay
	// While its definition is of type kZeroDelay
	float 	fVeeec0State; // Single Delay
	int fSampleRate;

  public:
	virtual void metadata(Meta* m) { 
		m->declare("filename", "bs.dsp");
		m->declare("name", "bs");
	}

	virtual int getNumInputs() { return 0; }
	virtual int getNumOutputs() { return 1; }
	static void classInit(int sample_rate) {
	}
	virtual void instanceConstants(int sample_rate) {
		fSampleRate = sample_rate;
	}
	virtual void instanceResetUserInterface() {
	}
	virtual void instanceClear() {
		fVeeec0State = 0;
	}
	virtual void init(int sample_rate) {
		classInit(sample_rate);
		instanceInit(sample_rate);
	}
	virtual void instanceInit(int sample_rate) {
		instanceConstants(sample_rate);
		instanceResetUserInterface();
		instanceClear();
	}
	virtual mydsp* clone() {
		return new mydsp();
	}
	virtual int getSampleRate() {
		return fSampleRate;
	}
	virtual void buildUserInterface(UI* ui_interface) {
		ui_interface->openVerticalBox("bs");
		ui_interface->closeBox();
	}
	virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
		float 	fSlow0 = (1e+01f / float(count)); // step: 5
		float 	fVeeec0[2];
		int fullcount = count;
		for (int index = 0; index < fullcount; index += 32) {
			int count = min(32, fullcount-index);
			FAUSTFLOAT* output0 = &output[0][index]; // Zone 3
			fVeeec0[1] = fVeeec0State;
			for (int i=0; i<count; i++) {
				float 	fTemp0 = fVeeec0[1]; // step: 7
				float 	fTemp1 = (fSlow0 + fTemp0); // step: 8
				float 	fTemp2 = (fTemp0 - fSlow0); // step: 10
				fVeeec0[0] = (((fTemp1 < 1e+01f)) ? fTemp1 : (((fTemp2 > 1e+01f)) ? fTemp2 : 1e+01f));
				output0[i] = (FAUSTFLOAT)(fVeeec0[0]);  // Zone Exec Code
				// post processing
				fVeeec0[1] = fVeeec0[0];
			}
			fVeeec0State = fVeeec0[1];
		}
	}
};


