File: table.cpp1

package info (click to toggle)
faust 2.79.3%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 397,496 kB
  • sloc: cpp: 278,433; ansic: 116,164; javascript: 18,529; vhdl: 14,052; sh: 13,884; java: 5,900; objc: 3,852; python: 3,222; makefile: 2,655; cs: 1,672; lisp: 1,146; ruby: 954; yacc: 586; xml: 471; lex: 247; awk: 110; tcl: 26
file content (166 lines) | stat: -rw-r--r-- 5,754 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//----------------------------------------------------------
// name: "table"
//
// 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;
		// Recursion delay iVeeec4 is of type kMonoDelay
		// While its definition is of type kZeroDelay
		int 	iVeeec4State; // Mono Delay
		// Recursion delay fVeeec2 is of type kCopyDelay
		// While its definition is of type kZeroDelay
		float 	fVeeec2State[3]; // Copy Delay
	  public:
		int getNumInputs() { return 0; }
		int getNumOutputs() { return 1; }
		void init(int sample_rate) {
			fSampleRate = sample_rate;
			iVeeec4State = 0;
			for (int j = 0; j < 3; j++) { fVeeec2State[j] = 0; }
		}
		void fill(int count, float output[]) {
			int 	iVeeec4;
			float 	fVeeec2[4];
			int fullcount = count;
			for (int index = 0; index < fullcount; index += 32) {
				int count = min(32, fullcount-index);
				iVeeec4 = iVeeec4State;
				fVeeec2[1] = fVeeec2State[0];
				fVeeec2[2] = fVeeec2State[1];
				fVeeec2[3] = fVeeec2State[2];
				for (int i=0; i<count; i++) {
					float 	fTemp1 = fVeeec2[2]; // step: 29
					float 	fTemp2 = fVeeec2[3]; // step: 32
					iVeeec4 = ((1103515245 * iVeeec4) + 12345);
					float 	fTemp3 = fVeeec2[1]; // step: 46
					fVeeec2[0] = (((0.5221894f * fTemp2) + ((4.656613e-10f * float(iVeeec4)) + (2.494956f * fTemp3))) - (2.0172658f * fTemp1));
					output[i] = (((0.049922034f * fVeeec2[0]) + (0.0506127f * fTemp1)) - ((0.095993534f * fTemp3) + (0.004408786f * fTemp2)));
					// post processing
					fVeeec2[3] = fVeeec2[2];
					fVeeec2[2] = fVeeec2[1];
					fVeeec2[1] = fVeeec2[0];
				}
				iVeeec4State = iVeeec4;
				fVeeec2State[0] = fVeeec2[1];
				fVeeec2State[1] = fVeeec2[2];
				fVeeec2State[2] = fVeeec2[3];
				output += 32;
			}
		}
	};


	FAUSTFLOAT 	fslider0;
	float 	fConst0; // step: 10
	// Recursion delay fVeeec0 is of type kSingleDelay
	// While its definition is of type kZeroDelay
	float 	fVeeec0State; // Single Delay
	static float 	ftbl0[65536];
	int fSampleRate;

  public:
	virtual void metadata(Meta* m) { 
		m->declare("compilation_options", "-single -scal -e table.dsp -o table.dsp");
		m->declare("filename", "table.dsp");
		m->declare("filters_lib_fir_author", "Julius O. Smith III");
		m->declare("filters_lib_fir_copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
		m->declare("filters_lib_fir_license", "MIT-style STK-4.3 license");
		m->declare("filters_lib_iir_author", "Julius O. Smith III");
		m->declare("filters_lib_iir_copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
		m->declare("filters_lib_iir_license", "MIT-style STK-4.3 license");
		m->declare("filters_lib_lowpass0_highpass1", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
		m->declare("filters_lib_name", "Faust Filters Library");
		m->declare("filters_lib_version", "0.3");
		m->declare("library_path", "/usr/local/share/faust/stdfaust.lib");
		m->declare("maths_lib_author", "GRAME");
		m->declare("maths_lib_copyright", "GRAME");
		m->declare("maths_lib_license", "LGPL with exception");
		m->declare("maths_lib_name", "Faust Math Library");
		m->declare("maths_lib_version", "2.3");
		m->declare("name", "table");
		m->declare("noises_lib_name", "Faust Noise Generator Library");
		m->declare("noises_lib_version", "0.0");
		m->declare("oscillators_lib_name", "Faust Oscillator Library");
		m->declare("oscillators_lib_version", "0.1");
		m->declare("platform_lib_name", "Generic Platform Library");
		m->declare("platform_lib_version", "0.1");
	}

	virtual int getNumInputs() { return 0; }
	virtual int getNumOutputs() { return 2; }
	static void classInit(int sample_rate) {
		SIG0 sig0;
		sig0.init(sample_rate);
		sig0.fill(65536,ftbl0);
	}
	virtual void instanceConstants(int sample_rate) {
		fSampleRate = sample_rate;
		fConst0 = (1.0f / min(1.92e+05f, max(1.0f, float(fSampleRate)))); // step: 10
	}
	virtual void instanceResetUserInterface() {
		fslider0 = 4.4e+02f;
	}
	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("table");
		ui_interface->addHorizontalSlider("freq", &fslider0, 4.4e+02f, 5e+01f, 2e+03f, 0.01f);
		ui_interface->closeBox();
	}
	virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
		float 	fSlow0 = (fConst0 * float(fslider0)); // step: 11
		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
			FAUSTFLOAT* output1 = &output[1][index]; // Zone 3
			fVeeec0[1] = fVeeec0State;
			for (int i=0; i<count; i++) {
				float 	fTemp0 = fVeeec0[1]; // step: 13
				fVeeec0[0] = (fSlow0 + (fTemp0 - floorf((fSlow0 + fTemp0))));
				float 	fTemp4 = ftbl0[max(0, min(int((65536.0f * fVeeec0[0])), 65535))]; // step: 64
				output0[i] = (FAUSTFLOAT)(fTemp4);  // Zone Exec Code
				output1[i] = (FAUSTFLOAT)(fTemp4);  // Zone Exec Code
				// post processing
				fVeeec0[1] = fVeeec0[0];
			}
			fVeeec0State = fVeeec0[1];
		}
	}
};


float 	mydsp::ftbl0[65536];