//----------------------------------------------------------
// name: "waveform3"
//
// Code generated with Faust 2.77.2 (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:
	class SIG0 {
	  private:
		int fSampleRate;
		static float 	fWave0[7];
		int 	idxfWave0;
	  public:
		int getNumInputs() { return 0; }
		int getNumOutputs() { return 1; }
		void init(int sample_rate) {
			fSampleRate = sample_rate;
			idxfWave0 = 0;
		}
		void fill(int count, float output[]) {
			int fullcount = count;
			for (int index = 0; index < fullcount; index += 32) {
				int count = min(32, fullcount-index);
				for (int i=0; i<count; i++) {
					output[i] = fWave0[idxfWave0];
					// post processing
					idxfWave0 = (idxfWave0 + 1) % 7;
				}
				output += 32;
			}
		}
	};


	// Recursion delay iVeeec0 is of type kMonoDelay
	// While its definition is of type kZeroDelay
	int 	iVeeec0State; // Mono Delay
	static float 	ftbl0[7];
	int fSampleRate;

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

	virtual int getNumInputs() { return 0; }
	virtual int getNumOutputs() { return 1; }
	static void classInit(int sample_rate) {
		SIG0 sig0;
		sig0.init(sample_rate);
		sig0.fill(7,ftbl0);
	}
	virtual void instanceConstants(int sample_rate) {
		fSampleRate = sample_rate;
	}
	virtual void instanceResetUserInterface() {
	}
	virtual void instanceClear() {
		iVeeec0State = 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("waveform3");
		ui_interface->closeBox();
	}
	virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
		int 	iVeeec0;
		int fullcount = count;
		for (int index = 0; index < fullcount; index += 32) {
			int count = min(32, fullcount-index);
			FAUSTFLOAT* output0 = &output[0][index]; // Zone 3
			iVeeec0 = iVeeec0State;
			for (int i=0; i<count; i++) {
				iVeeec0 = ((iVeeec0 + 3) % 7);
				output0[i] = (FAUSTFLOAT)(ftbl0[max(0, min(iVeeec0, 6))]);  // Zone Exec Code
			}
			iVeeec0State = iVeeec0;
		}
	}
};


float 	mydsp::SIG0::fWave0[7] = {1.1f,2.2f,3.3f,4.4f,5.5f,6.6f,7.7f};
float 	mydsp::ftbl0[7];
