1 // generated from file '../src/LV2/faust/chorus_mono.dsp' by dsp2cc:
2 // Code generated with Faust (https://faust.grame.fr)
3
4
5 namespace chorus_mono {
6 class mydspSIG0 {
7
8 private:
9
10 int iRec6[2];
11
12 public:
13
getNumInputsmydspSIG0()14 int getNumInputsmydspSIG0() {
15 return 0;
16 }
getNumOutputsmydspSIG0()17 int getNumOutputsmydspSIG0() {
18 return 1;
19 }
20
instanceInitmydspSIG0(int sample_rate)21 void instanceInitmydspSIG0(int sample_rate) {
22 for (int l3 = 0; (l3 < 2); l3 = (l3 + 1)) {
23 iRec6[l3] = 0;
24 }
25 }
26
fillmydspSIG0(int count,double * table)27 void fillmydspSIG0(int count, double* table) {
28 for (int i1 = 0; (i1 < count); i1 = (i1 + 1)) {
29 iRec6[0] = (iRec6[1] + 1);
30 table[i1] = std::sin((9.5873799242852573e-05 * double((iRec6[0] + -1))));
31 iRec6[1] = iRec6[0];
32 }
33 }
34
35 };
36
newmydspSIG0()37 static mydspSIG0* newmydspSIG0() { return (mydspSIG0*)new mydspSIG0(); }
deletemydspSIG0(mydspSIG0 * dsp)38 static void deletemydspSIG0(mydspSIG0* dsp) { delete dsp; }
39
40 static double ftbl0mydspSIG0[65536];
41
42
43 class Dsp: public PluginLV2 {
44 private:
45 uint32_t fSampleRate;
46 FAUSTFLOAT fHslider0;
47 FAUSTFLOAT *fHslider0_;
48 double fRec0[2];
49 FAUSTFLOAT fVslider0;
50 FAUSTFLOAT *fVslider0_;
51 int IOTA;
52 double fVec0[131072];
53 double fConst1;
54 double fConst2;
55 FAUSTFLOAT fHslider1;
56 FAUSTFLOAT *fHslider1_;
57 double fRec5[2];
58 double fConst3;
59 double fConst4;
60 double fRec1[2];
61 double fRec2[2];
62 double fRec3[2];
63 double fRec4[2];
64
65 void connect(uint32_t port,void* data);
66 void clear_state_f();
67 void init(uint32_t sample_rate);
68 void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
69
70 static void clear_state_f_static(PluginLV2*);
71 static void init_static(uint32_t sample_rate, PluginLV2*);
72 static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginLV2*);
73 static void del_instance(PluginLV2 *p);
74 static void connect_static(uint32_t port,void* data, PluginLV2 *p);
75 public:
76 Dsp();
77 ~Dsp();
78 };
79
80
81
Dsp()82 Dsp::Dsp()
83 : PluginLV2() {
84 version = PLUGINLV2_VERSION;
85 id = "chorus_mono";
86 name = N_("Chorus Mono");
87 mono_audio = compute_static;
88 stereo_audio = 0;
89 set_samplerate = init_static;
90 activate_plugin = 0;
91 connect_ports = connect_static;
92 clear_state = clear_state_f_static;
93 delete_instance = del_instance;
94 }
95
~Dsp()96 Dsp::~Dsp() {
97 }
98
clear_state_f()99 inline void Dsp::clear_state_f()
100 {
101 for (int l0 = 0; (l0 < 2); l0 = (l0 + 1)) fRec0[l0] = 0.0;
102 for (int l1 = 0; (l1 < 131072); l1 = (l1 + 1)) fVec0[l1] = 0.0;
103 for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) fRec5[l2] = 0.0;
104 for (int l4 = 0; (l4 < 2); l4 = (l4 + 1)) fRec1[l4] = 0.0;
105 for (int l5 = 0; (l5 < 2); l5 = (l5 + 1)) fRec2[l5] = 0.0;
106 for (int l6 = 0; (l6 < 2); l6 = (l6 + 1)) fRec3[l6] = 0.0;
107 for (int l7 = 0; (l7 < 2); l7 = (l7 + 1)) fRec4[l7] = 0.0;
108 }
109
clear_state_f_static(PluginLV2 * p)110 void Dsp::clear_state_f_static(PluginLV2 *p)
111 {
112 static_cast<Dsp*>(p)->clear_state_f();
113 }
114
init(uint32_t sample_rate)115 inline void Dsp::init(uint32_t sample_rate)
116 {
117 mydspSIG0* sig0 = newmydspSIG0();
118 sig0->instanceInitmydspSIG0(sample_rate);
119 sig0->fillmydspSIG0(65536, ftbl0mydspSIG0);
120 deletemydspSIG0(sig0);
121 fSampleRate = sample_rate;
122 double fConst0 = std::min<double>(192000.0, std::max<double>(1.0, double(fSampleRate)));
123 fConst1 = (0.01 * fConst0);
124 fConst2 = (1.0 / fConst0);
125 fConst3 = (1000.0 / fConst0);
126 fConst4 = (0.0 - fConst3);
127 IOTA = 0;
128 clear_state_f();
129 }
130
init_static(uint32_t sample_rate,PluginLV2 * p)131 void Dsp::init_static(uint32_t sample_rate, PluginLV2 *p)
132 {
133 static_cast<Dsp*>(p)->init(sample_rate);
134 }
135
compute(int count,FAUSTFLOAT * input0,FAUSTFLOAT * output0)136 void always_inline Dsp::compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0)
137 {
138 #define fHslider0 (*fHslider0_)
139 #define fVslider0 (*fVslider0_)
140 #define fHslider1 (*fHslider1_)
141 double fSlow0 = (0.0070000000000000062 * double(fHslider0));
142 double fSlow1 = (0.01 * double(fVslider0));
143 double fSlow2 = (fConst2 * double(fHslider1));
144 double fSlow3 = (fSlow1 + (1.0 - fSlow1));
145 for (int i0 = 0; (i0 < count); i0 = (i0 + 1)) {
146 fRec0[0] = (fSlow0 + (0.99299999999999999 * fRec0[1]));
147 double fTemp0 = double(input0[i0]);
148 double fTemp1 = (fSlow1 * fTemp0);
149 fVec0[(IOTA & 131071)] = fTemp1;
150 fRec5[0] = (fSlow2 + (fRec5[1] - std::floor((fSlow2 + fRec5[1]))));
151 double fTemp2 = (65536.0 * (fRec5[0] - std::floor(fRec5[0])));
152 double fTemp3 = std::floor(fTemp2);
153 int iTemp4 = int(fTemp3);
154 double fTemp5 = (fConst1 * ((0.02 * (((fTemp3 + (1.0 - fTemp2)) * ftbl0mydspSIG0[(iTemp4 & 65535)]) + ((fTemp2 - fTemp3) * ftbl0mydspSIG0[((iTemp4 + 1) & 65535)]))) + 1.0));
155 double fThen1 = (((fRec2[1] == 1.0) & (fTemp5 != fRec4[1])) ? fConst4 : 0.0);
156 double fThen3 = (((fRec2[1] == 0.0) & (fTemp5 != fRec3[1])) ? fConst3 : fThen1);
157 double fElse3 = (((fRec2[1] > 0.0) & (fRec2[1] < 1.0)) ? fRec1[1] : 0.0);
158 double fTemp6 = ((fRec1[1] != 0.0) ? fElse3 : fThen3);
159 fRec1[0] = fTemp6;
160 fRec2[0] = std::max<double>(0.0, std::min<double>(1.0, (fRec2[1] + fTemp6)));
161 fRec3[0] = (((fRec2[1] >= 1.0) & (fRec4[1] != fTemp5)) ? fTemp5 : fRec3[1]);
162 fRec4[0] = (((fRec2[1] <= 0.0) & (fRec3[1] != fTemp5)) ? fTemp5 : fRec4[1]);
163 double fTemp7 = fVec0[((IOTA - int(std::min<double>(65536.0, std::max<double>(0.0, fRec3[0])))) & 131071)];
164 output0[i0] = FAUSTFLOAT(((fRec0[0] * (fTemp7 + (fRec2[0] * (fVec0[((IOTA - int(std::min<double>(65536.0, std::max<double>(0.0, fRec4[0])))) & 131071)] - fTemp7)))) + (fSlow3 * fTemp0)));
165 fRec0[1] = fRec0[0];
166 IOTA = (IOTA + 1);
167 fRec5[1] = fRec5[0];
168 fRec1[1] = fRec1[0];
169 fRec2[1] = fRec2[0];
170 fRec3[1] = fRec3[0];
171 fRec4[1] = fRec4[0];
172 }
173 #undef fHslider0
174 #undef fVslider0
175 #undef fHslider1
176 }
177
compute_static(int count,FAUSTFLOAT * input0,FAUSTFLOAT * output0,PluginLV2 * p)178 void __rt_func Dsp::compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginLV2 *p)
179 {
180 static_cast<Dsp*>(p)->compute(count, input0, output0);
181 }
182
183
connect(uint32_t port,void * data)184 void Dsp::connect(uint32_t port,void* data)
185 {
186 switch ((PortIndex)port)
187 {
188 case FREQ:
189 fHslider1_ = (float*)data; // , 2.0, 0.0, 10.0, 0.01
190 break;
191 case LEVEL:
192 fHslider0_ = (float*)data; // , 0.5, 0.0, 1.0, 0.01
193 break;
194 case WET_DRY:
195 fVslider0_ = (float*)data; // , 100.0, 0.0, 100.0, 1.0
196 break;
197 default:
198 break;
199 }
200 }
201
connect_static(uint32_t port,void * data,PluginLV2 * p)202 void Dsp::connect_static(uint32_t port,void* data, PluginLV2 *p)
203 {
204 static_cast<Dsp*>(p)->connect(port, data);
205 }
206
207
plugin()208 PluginLV2 *plugin() {
209 return new Dsp();
210 }
211
del_instance(PluginLV2 * p)212 void Dsp::del_instance(PluginLV2 *p)
213 {
214 delete static_cast<Dsp*>(p);
215 }
216
217 /*
218 typedef enum
219 {
220 FREQ,
221 LEVEL,
222 WET_DRY,
223 } PortIndex;
224 */
225
226 } // end namespace chorus_mono
227