//----------------------------------------------------------
// name: "waveform6"
//
// 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:
	class SIG0 {
	  private:
		int fSampleRate;
		static int 	iWave0[6];
		int 	idxiWave0;
	  public:
		int getNumInputs() { return 0; }
		int getNumOutputs() { return 1; }
		void init(int sample_rate) {
			fSampleRate = sample_rate;
			idxiWave0 = 0;
		}
		void fill(int count, int 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] = iWave0[idxiWave0];
					// post processing
					idxiWave0 = (idxiWave0 + 1) % 6;
				}
				output += 32;
			}
		}
	};


	static int 	itbl0[6];
	int fSampleRate;

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

	virtual int getNumInputs() { return 2; }
	virtual int getNumOutputs() { return 1; }
	static void classInit(int sample_rate) {
		SIG0 sig0;
		sig0.init(sample_rate);
		sig0.fill(6,itbl0);
	}
	virtual void instanceConstants(int sample_rate) {
		fSampleRate = sample_rate;
	}
	virtual void instanceResetUserInterface() {
	}
	virtual void instanceClear() {
	}
	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("waveform6");
		ui_interface->closeBox();
	}
	virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
		int fullcount = count;
		for (int index = 0; index < fullcount; index += 32) {
			int count = min(32, fullcount-index);
			FAUSTFLOAT* input0 = &input[0][index]; // Zone 3
			FAUSTFLOAT* input1 = &input[1][index]; // Zone 3
			FAUSTFLOAT* output0 = &output[0][index]; // Zone 3
			for (int i=0; i<count; i++) {
				output0[i] = (FAUSTFLOAT)(((float)input1[i] * sinf(float(itbl0[int((4.0f * fabsf((float)input0[i])))]))));  // Zone Exec Code
			}
		}
	}
};


int 	mydsp::SIG0::iWave0[6] = {10,20,30,40,50,60};
int 	mydsp::itbl0[6];
