1 // generated from file '../src/faust/tonestack_mlead.dsp' by dsp2cc:
2 // Code generated with Faust (https://faust.grame.fr)
3 
4 
5 namespace tonestack_mlead {
6 
7 class Dsp: public PluginDef {
8 private:
9 	int fSampleRate;
10 	double fConst0;
11 	FAUSTFLOAT fVslider0;
12 	FAUSTFLOAT	*fVslider0_;
13 	FAUSTFLOAT fVslider1;
14 	FAUSTFLOAT	*fVslider1_;
15 	double fConst1;
16 	FAUSTFLOAT fVslider2;
17 	FAUSTFLOAT	*fVslider2_;
18 	double fConst2;
19 	double fRec0[4];
20 
21 	void clear_state_f();
22 	void init(unsigned int sample_rate);
23 	void compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0);
24 	int register_par(const ParamReg& reg);
25 
26 	static void clear_state_f_static(PluginDef*);
27 	static void init_static(unsigned int sample_rate, PluginDef*);
28 	static void compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef*);
29 	static int register_params_static(const ParamReg& reg);
30 	static void del_instance(PluginDef *p);
31 public:
32 	Dsp();
33 	~Dsp();
34 };
35 
36 
37 
Dsp()38 Dsp::Dsp()
39 	: PluginDef() {
40 	version = PLUGINDEF_VERSION;
41 	flags = 0;
42 	id = "M-Lead";
43 	name = N_("M-Lead Style");
44 	groups = 0;
45 	description = ""; // description (tooltip)
46 	category = "";       // category
47 	shortname = "";     // shortname
48 	mono_audio = compute_static;
49 	stereo_audio = 0;
50 	set_samplerate = init_static;
51 	activate_plugin = 0;
52 	register_params = register_params_static;
53 	load_ui = 0;
54 	clear_state = clear_state_f_static;
55 	delete_instance = del_instance;
56 }
57 
~Dsp()58 Dsp::~Dsp() {
59 }
60 
clear_state_f()61 inline void Dsp::clear_state_f()
62 {
63 	for (int l0 = 0; (l0 < 4); l0 = (l0 + 1)) fRec0[l0] = 0.0;
64 }
65 
clear_state_f_static(PluginDef * p)66 void Dsp::clear_state_f_static(PluginDef *p)
67 {
68 	static_cast<Dsp*>(p)->clear_state_f();
69 }
70 
init(unsigned int sample_rate)71 inline void Dsp::init(unsigned int sample_rate)
72 {
73 	fSampleRate = sample_rate;
74 	fConst0 = (2.0 * std::min<double>(192000.0, std::max<double>(1.0, double(fSampleRate))));
75 	fConst1 = mydsp_faustpower2_f(fConst0);
76 	fConst2 = (3.0 * fConst0);
77 	clear_state_f();
78 }
79 
init_static(unsigned int sample_rate,PluginDef * p)80 void Dsp::init_static(unsigned int sample_rate, PluginDef *p)
81 {
82 	static_cast<Dsp*>(p)->init(sample_rate);
83 }
84 
compute(int count,FAUSTFLOAT * input0,FAUSTFLOAT * output0)85 void always_inline Dsp::compute(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0)
86 {
87 #define fVslider0 (*fVslider0_)
88 #define fVslider1 (*fVslider1_)
89 #define fVslider2 (*fVslider2_)
90 	double fSlow0 = double(fVslider0);
91 	double fSlow1 = std::exp((3.3999999999999999 * (double(fVslider1) + -1.0)));
92 	double fSlow2 = ((0.00055000000000000003 * fSlow0) + (0.022500000000000003 * fSlow1));
93 	double fSlow3 = (fConst0 * (fSlow2 + 0.0021395000000000003));
94 	double fSlow4 = (3.0937500000000006e-07 * fSlow0);
95 	double fSlow5 = (((fSlow0 * (((1.2375000000000003e-05 * fSlow1) + -2.1175000000000003e-08) - fSlow4)) + (1.9448000000000004e-05 * fSlow1)) + 6.6770000000000008e-07);
96 	double fSlow6 = ((1.7121500000000001e-09 * fSlow1) - (4.2803750000000003e-11 * fSlow0));
97 	double fSlow7 = (1.9965000000000003e-09 * fSlow1);
98 	double fSlow8 = (((fSlow0 * (fSlow6 + -7.108750000000004e-12)) + fSlow7) + 4.9912500000000007e-11);
99 	double fSlow9 = (fConst0 * fSlow8);
100 	double fSlow10 = (1.0 / (-1.0 - (fSlow3 + (fConst1 * (fSlow5 + fSlow9)))));
101 	double fSlow11 = double(fVslider2);
102 	double fSlow12 = (fConst0 * ((fSlow2 + (0.000125 * fSlow11)) + 0.00056250000000000007));
103 	double fSlow13 = (((1.815e-07 * fSlow11) + ((fSlow0 * (3.7812500000000009e-07 - fSlow4)) + (fSlow1 * ((1.2375000000000003e-05 * fSlow0) + 3.4760000000000007e-06)))) + 8.6900000000000017e-08);
104 	double fSlow14 = ((fSlow0 * (fSlow6 + 4.2803750000000003e-11)) + (fSlow11 * (fSlow7 - (4.9912500000000007e-11 * (fSlow0 + -1.0)))));
105 	double fSlow15 = (fConst0 * fSlow14);
106 	double fSlow16 = (0.0 - (fSlow12 + (fConst1 * (fSlow13 + fSlow15))));
107 	double fSlow17 = (fConst2 * fSlow8);
108 	double fSlow18 = ((fConst1 * (fSlow5 + fSlow17)) + (-3.0 - fSlow3));
109 	double fSlow19 = ((fSlow3 + (fConst1 * (fSlow5 - fSlow17))) + -3.0);
110 	double fSlow20 = (fSlow3 + (-1.0 - (fConst1 * (fSlow5 - fSlow9))));
111 	double fSlow21 = (fConst2 * fSlow14);
112 	double fSlow22 = ((fConst1 * (fSlow13 + fSlow21)) - fSlow12);
113 	double fSlow23 = (fSlow12 + (fConst1 * (fSlow13 - fSlow21)));
114 	double fSlow24 = (fSlow12 - (fConst1 * (fSlow13 - fSlow15)));
115 	for (int i0 = 0; (i0 < count); i0 = (i0 + 1)) {
116 		fRec0[0] = (double(input0[i0]) - (fSlow10 * (((fSlow18 * fRec0[1]) + (fSlow19 * fRec0[2])) + (fSlow20 * fRec0[3]))));
117 		output0[i0] = FAUSTFLOAT((fSlow10 * ((((fSlow16 * fRec0[0]) + (fSlow22 * fRec0[1])) + (fSlow23 * fRec0[2])) + (fSlow24 * fRec0[3]))));
118 		for (int j0 = 3; (j0 > 0); j0 = (j0 - 1)) {
119 			fRec0[j0] = fRec0[(j0 - 1)];
120 		}
121 	}
122 #undef fVslider0
123 #undef fVslider1
124 #undef fVslider2
125 }
126 
compute_static(int count,FAUSTFLOAT * input0,FAUSTFLOAT * output0,PluginDef * p)127 void __rt_func Dsp::compute_static(int count, FAUSTFLOAT *input0, FAUSTFLOAT *output0, PluginDef *p)
128 {
129 	static_cast<Dsp*>(p)->compute(count, input0, output0);
130 }
131 
register_par(const ParamReg & reg)132 int Dsp::register_par(const ParamReg& reg)
133 {
134 	fVslider1_ = reg.registerFloatVar("amp.tonestack.Bass","","SA","",&fVslider1, 0.5, 0.0, 1.0, 0.01, 0);
135 	fVslider0_ = reg.registerFloatVar("amp.tonestack.Middle","","SA","",&fVslider0, 0.5, 0.0, 1.0, 0.01, 0);
136 	fVslider2_ = reg.registerFloatVar("amp.tonestack.Treble","","SA","",&fVslider2, 0.5, 0.0, 1.0, 0.01, 0);
137 	return 0;
138 }
139 
register_params_static(const ParamReg & reg)140 int Dsp::register_params_static(const ParamReg& reg)
141 {
142 	return static_cast<Dsp*>(reg.plugin)->register_par(reg);
143 }
144 
plugin()145 PluginDef *plugin() {
146 	return new Dsp();
147 }
148 
del_instance(PluginDef * p)149 void Dsp::del_instance(PluginDef *p)
150 {
151 	delete static_cast<Dsp*>(p);
152 }
153 
154 } // end namespace tonestack_mlead
155