1 // generated from file '../src/LV2/faust/duck_delay.dsp' by dsp2cc:
2 // Code generated with Faust (https://faust.grame.fr)
3 
4 
5 namespace duck_delay {
6 
7 class Dsp: public PluginLV2 {
8 private:
9 	uint32_t fSampleRate;
10 	FAUSTFLOAT fHslider0;
11 	FAUSTFLOAT	*fHslider0_;
12 	int IOTA;
13 	double fVec0[524288];
14 	double fConst1;
15 	double fConst2;
16 	double fConst3;
17 	FAUSTFLOAT fHslider1;
18 	FAUSTFLOAT	*fHslider1_;
19 	double fRec1[2];
20 	double fRec0[2];
21 	FAUSTFLOAT fHslider2;
22 	FAUSTFLOAT	*fHslider2_;
23 	FAUSTFLOAT fHslider3;
24 	FAUSTFLOAT	*fHslider3_;
25 	double fConst4;
26 	FAUSTFLOAT fHslider4;
27 	FAUSTFLOAT	*fHslider4_;
28 	double fRec4[2];
29 	double fRec3[2];
30 	double fRec2[2];
31 
32 	void connect(uint32_t port,void* data);
33 	void clear_state_f();
34 	void init(uint32_t sample_rate);
35 	void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
36 
37 	static void clear_state_f_static(PluginLV2*);
38 	static void init_static(uint32_t sample_rate, PluginLV2*);
39 	static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginLV2*);
40 	static void del_instance(PluginLV2 *p);
41 	static void connect_static(uint32_t port,void* data, PluginLV2 *p);
42 public:
43 	Dsp();
44 	~Dsp();
45 };
46 
47 
48 
Dsp()49 Dsp::Dsp()
50 	: PluginLV2() {
51 	version = PLUGINLV2_VERSION;
52 	id = "duckDelay";
53 	name = N_("Duck Delay");
54 	mono_audio = compute_static;
55 	stereo_audio = 0;
56 	set_samplerate = init_static;
57 	activate_plugin = 0;
58 	connect_ports = connect_static;
59 	clear_state = clear_state_f_static;
60 	delete_instance = del_instance;
61 }
62 
~Dsp()63 Dsp::~Dsp() {
64 }
65 
clear_state_f()66 inline void Dsp::clear_state_f()
67 {
68 	for (int l0 = 0; (l0 < 524288); l0 = (l0 + 1)) fVec0[l0] = 0.0;
69 	for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) fRec1[l1] = 0.0;
70 	for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) fRec0[l2] = 0.0;
71 	for (int l3 = 0; (l3 < 2); l3 = (l3 + 1)) fRec4[l3] = 0.0;
72 	for (int l4 = 0; (l4 < 2); l4 = (l4 + 1)) fRec3[l4] = 0.0;
73 	for (int l5 = 0; (l5 < 2); l5 = (l5 + 1)) fRec2[l5] = 0.0;
74 }
75 
clear_state_f_static(PluginLV2 * p)76 void Dsp::clear_state_f_static(PluginLV2 *p)
77 {
78 	static_cast<Dsp*>(p)->clear_state_f();
79 }
80 
init(uint32_t sample_rate)81 inline void Dsp::init(uint32_t sample_rate)
82 {
83 	fSampleRate = sample_rate;
84 	double fConst0 = std::min<double>(192000.0, std::max<double>(1.0, double(fSampleRate)));
85 	fConst1 = (0.001 * fConst0);
86 	fConst2 = std::exp((0.0 - (10.0 / fConst0)));
87 	fConst3 = (1.0 - fConst2);
88 	fConst4 = (1.0 / fConst0);
89 	IOTA = 0;
90 	clear_state_f();
91 }
92 
init_static(uint32_t sample_rate,PluginLV2 * p)93 void Dsp::init_static(uint32_t sample_rate, PluginLV2 *p)
94 {
95 	static_cast<Dsp*>(p)->init(sample_rate);
96 }
97 
compute(int count,FAUSTFLOAT * input0,FAUSTFLOAT * output0)98 void always_inline Dsp::compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0)
99 {
100 #define fHslider0 (*fHslider0_)
101 #define fHslider1 (*fHslider1_)
102 #define fHslider2 (*fHslider2_)
103 #define fHslider3 (*fHslider3_)
104 #define fHslider4 (*fHslider4_)
105 	double fSlow0 = double(fHslider0);
106 	double fSlow1 = (fConst3 * double(fHslider1));
107 	double fSlow2 = std::pow(10.0, (0.050000000000000003 * double(fHslider2)));
108 	double fSlow3 = double(fHslider3);
109 	int iSlow4 = (std::fabs(fSlow3) < 2.2204460492503131e-16);
110 	double fThen1 = std::exp((0.0 - (fConst4 / (iSlow4 ? 1.0 : fSlow3))));
111 	double fSlow5 = (iSlow4 ? 0.0 : fThen1);
112 	double fSlow6 = double(fHslider4);
113 	int iSlow7 = (std::fabs(fSlow6) < 2.2204460492503131e-16);
114 	double fThen3 = std::exp((0.0 - (fConst4 / (iSlow7 ? 1.0 : fSlow6))));
115 	double fSlow8 = (iSlow7 ? 0.0 : fThen3);
116 	double fSlow9 = (1.0 - fSlow8);
117 	double fSlow10 = (1.0 - fSlow5);
118 	for (int i0 = 0; (i0 < count); i0 = (i0 + 1)) {
119 		double fTemp0 = double(input0[i0]);
120 		double fTemp1 = (fTemp0 + (fSlow0 * fRec0[1]));
121 		fVec0[(IOTA & 524287)] = fTemp1;
122 		fRec1[0] = (fSlow1 + (fConst2 * fRec1[1]));
123 		double fTemp2 = (fConst1 * fRec1[0]);
124 		int iTemp3 = int(fTemp2);
125 		double fTemp4 = std::floor(fTemp2);
126 		fRec0[0] = ((fVec0[((IOTA - std::min<int>(393217, std::max<int>(0, iTemp3))) & 524287)] * (fTemp4 + (1.0 - fTemp2))) + ((fTemp2 - fTemp4) * fVec0[((IOTA - std::min<int>(393217, std::max<int>(0, (iTemp3 + 1)))) & 524287)]));
127 		double fTemp5 = std::fabs(fTemp0);
128 		fRec4[0] = std::max<double>(fTemp5, ((fRec4[1] * fSlow8) + (fTemp5 * fSlow9)));
129 		fRec3[0] = ((fRec3[1] * fSlow5) + (fRec4[0] * fSlow10));
130 		fRec2[0] = ((fConst2 * fRec2[1]) + (fConst3 * double((1 - ((fSlow2 * fRec3[0]) > 1.0)))));
131 		output0[i0] = FAUSTFLOAT((fTemp0 + (fRec0[0] * fRec2[0])));
132 		IOTA = (IOTA + 1);
133 		fRec1[1] = fRec1[0];
134 		fRec0[1] = fRec0[0];
135 		fRec4[1] = fRec4[0];
136 		fRec3[1] = fRec3[0];
137 		fRec2[1] = fRec2[0];
138 	}
139 #undef fHslider0
140 #undef fHslider1
141 #undef fHslider2
142 #undef fHslider3
143 #undef fHslider4
144 }
145 
compute_static(int count,FAUSTFLOAT * input0,FAUSTFLOAT * output0,PluginLV2 * p)146 void __rt_func Dsp::compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginLV2 *p)
147 {
148 	static_cast<Dsp*>(p)->compute(count, input0, output0);
149 }
150 
151 
connect(uint32_t port,void * data)152 void Dsp::connect(uint32_t port,void* data)
153 {
154 	switch ((PortIndex)port)
155 	{
156 	case AMOUNT:
157 		fHslider2_ = (float*)data; // , 0.5, 0.0, 56.0, 0.050000000000000003
158 		break;
159 	case ATTACK:
160 		fHslider3_ = (float*)data; // , 0.10000000000000001, 0.050000000000000003, 0.5, 0.050000000000000003
161 		break;
162 	case FEEDBACK:
163 		fHslider0_ = (float*)data; // , 0.0, 0.0, 1.0, 0.050000000000000003
164 		break;
165 	case RELESE:
166 		fHslider4_ = (float*)data; // , 0.10000000000000001, 0.050000000000000003, 2.0, 0.050000000000000003
167 		break;
168 	case TIME:
169 		fHslider1_ = (float*)data; // , 500.0, 1.0, 2000.0, 1.0
170 		break;
171 	default:
172 		break;
173 	}
174 }
175 
connect_static(uint32_t port,void * data,PluginLV2 * p)176 void Dsp::connect_static(uint32_t port,void* data, PluginLV2 *p)
177 {
178 	static_cast<Dsp*>(p)->connect(port, data);
179 }
180 
181 
plugin()182 PluginLV2 *plugin() {
183 	return new Dsp();
184 }
185 
del_instance(PluginLV2 * p)186 void Dsp::del_instance(PluginLV2 *p)
187 {
188 	delete static_cast<Dsp*>(p);
189 }
190 
191 /*
192 typedef enum
193 {
194    AMOUNT,
195    ATTACK,
196    FEEDBACK,
197    RELESE,
198    TIME,
199 } PortIndex;
200 */
201 
202 } // end namespace duck_delay
203