Guitarix
cabinet_impulse_former.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3  * Copyright (C) 2011 Pete Shorthose
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
21 // generated from file '../src/faust/cabinet_impulse_former.dsp'
22 
23 FAUSTFLOAT& fslider0 = get_alias("cab.treble");
24 double fConst0;
25 double fConst1;
26 double fConst2;
27 FAUSTFLOAT& fslider1 = get_alias("cab.bass");
28 double fConst3;
29 double fConst4;
30 double fConst5;
31 double fVec0[3];
32 double fRec1[3];
33 double fRec0[3];
34 FAUSTFLOAT& fslider2 = get_alias("cab.Level");
36 
37 void init(int samplingFreq)
38 {
39  fSamplingFreq = samplingFreq;
40  fConst0 = (15079.644737231007 / fSamplingFreq);
41  fConst1 = cos(fConst0);
42  fConst2 = (1.4142135623730951 * sin(fConst0));
43  fConst3 = (1884.9555921538758 / fSamplingFreq);
44  fConst4 = cos(fConst3);
45  fConst5 = (1.4142135623730951 * sin(fConst3));
46  for (int i=0; i<3; i++) fVec0[i] = 0;
47  for (int i=0; i<3; i++) fRec1[i] = 0;
48  for (int i=0; i<3; i++) fRec0[i] = 0;
49 }
50 
51 void compute(int count, float *input0, float *output0)
52 {
53  double fSlow0 = pow(10,(0.025 * fslider0));
54  double fSlow1 = (1 + fSlow0);
55  double fSlow2 = (fConst1 * fSlow1);
56  double fSlow3 = (2 * (0 - ((1 + fSlow2) - fSlow0)));
57  double fSlow4 = (fConst1 * (fSlow0 - 1));
58  double fSlow5 = (fConst2 * sqrt(fSlow0));
59  double fSlow6 = (fSlow1 - (fSlow5 + fSlow4));
60  double fSlow7 = pow(10,(0.025 * fslider1));
61  double fSlow8 = (1 + fSlow7);
62  double fSlow9 = (fConst4 * fSlow8);
63  double fSlow10 = (0 - (2 * ((fSlow7 + fSlow9) - 1)));
64  double fSlow11 = (fConst5 * sqrt(fSlow7));
65  double fSlow12 = (fConst4 * (fSlow7 - 1));
66  double fSlow13 = ((1 + (fSlow7 + fSlow12)) - fSlow11);
67  double fSlow14 = (fSlow8 - (fSlow11 + fSlow12));
68  double fSlow15 = (2 * (0 - ((1 + fSlow9) - fSlow7)));
69  double fSlow16 = (fSlow7 + fSlow11);
70  double fSlow17 = ((1 + fSlow16) - fSlow12);
71  double fSlow18 = (1.0 / (1 + (fSlow12 + fSlow16)));
72  double fSlow19 = (fSlow0 * ((1 + (fSlow0 + fSlow4)) - fSlow5));
73  double fSlow20 = (fSlow0 + fSlow5);
74  double fSlow21 = (fSlow0 * (1 + (fSlow4 + fSlow20)));
75  double fSlow22 = (((fSlow0 + fSlow2) - 1) * (0 - (2 * fSlow0)));
76  double fSlow23 = (1.0 / ((1 + fSlow20) - fSlow4));
77  double fSlow24 = fslider2;
78  for (int i=0; i<count; i++) {
79  double fTemp0 = (double)input0[i];
80  fVec0[0] = fTemp0;
81  fRec1[0] = (fSlow18 * ((fSlow7 * (((fSlow17 * fVec0[0]) + (fSlow15 * fVec0[1])) + (fSlow14 * fVec0[2]))) - ((fSlow13 * fRec1[2]) + (fSlow10 * fRec1[1]))));
82  fRec0[0] = (fSlow23 * ((((fSlow22 * fRec1[1]) + (fSlow21 * fRec1[0])) + (fSlow19 * fRec1[2])) + (0 - ((fSlow6 * fRec0[2]) + (fSlow3 * fRec0[1])))));
83  output0[i] = (FAUSTFLOAT)(fSlow24 * fRec0[0]);
84  // post processing
85  fRec0[2] = fRec0[1]; fRec0[1] = fRec0[0];
86  fRec1[2] = fRec1[1]; fRec1[1] = fRec1[0];
87  fVec0[2] = fVec0[1]; fVec0[1] = fVec0[0];
88  }
89 }
90 
91 static struct RegisterParams { RegisterParams(); } RegisterParams;
92 RegisterParams::RegisterParams()
93 {
94  registerInit("cab", init);
95 }
96 
97 } // end namespace cabinet_impulse_former
void init(int samplingFreq)
#define FAUSTFLOAT
void compute(int count, float *input0, float *output0)