2 ==============================================================================
3 This file is part of Tal-Reverb by Patrick Kunz.
5 Copyright(c) 2005-2009 Patrick Kunz, TAL
9 This file may be licensed under the terms of of the
10 GNU General Public License Version 2 (the ``GPL'').
12 Software distributed under the License is distributed
13 on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14 express or implied. See the GPL for the specific language
15 governing rights and limitations.
17 You should have received a copy of the GPL along with this
18 program. If not, go to http://www.gnu.org/licenses/gpl.html
19 or write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 ==============================================================================
25 #if !defined(__ReverbEngine_h)
26 #define __ReverbEngine_h
29 #include "AudioUtils.h"
31 #include "ParamChangeUtil.h"
32 #include "NoiseGenerator.h"
40 ParamChangeUtil
* dryParamChange
;
41 ParamChangeUtil
* wetParamChange
;
43 NoiseGenerator
*noiseGenerator
;
49 AudioUtils audioUtils
;
51 ReverbEngine(float sampleRate
)
53 Params
*params
= new Params();
54 this->param
= params
->parameters
;
55 initialize(sampleRate
);
62 delete noiseGenerator
;
65 void setDry(float dry
)
67 this->dry
= audioUtils
.getLogScaledVolume(dry
, 2.0f
);
70 void setWet(float wet
)
72 this->wet
= audioUtils
.getLogScaledVolume(wet
, 2.0f
);
75 void setDecayTime(float decayTime
)
77 reverb
->setDecayTime(decayTime
);
80 void setPreDelay(float preDelay
)
82 reverb
->setPreDelay(preDelay
);
85 void setLowShelfGain(float lowShelfGain
)
87 reverb
->setLowShelfGain(lowShelfGain
);
90 void setHighShelfGain(float highShelfGain
)
92 reverb
->setHighShelfGain(highShelfGain
);
95 void setLowShelfFrequency(float lowShelfFrequency
)
97 reverb
->setLowShelfFrequency(lowShelfFrequency
);
100 void setHighShelfFrequency(float highShelfFrequency
)
102 reverb
->setHighShelfFrequency(highShelfFrequency
);
105 void setPeakFrequency(float peakFrequency
)
107 reverb
->setPeakFrequency(peakFrequency
);
110 void setPeakGain(float peakGain
)
112 reverb
->setPeakGain(peakGain
);
115 void setStereoWidth(float stereoWidth
)
117 this->stereoWidth
= stereoWidth
;
120 void setStereoMode(float stereoMode
)
122 reverb
->setStereoMode(stereoMode
> 0.0f
? true : false);
125 void setSampleRate(float sampleRate
)
127 initialize(sampleRate
);
130 void initialize(float sampleRate
)
134 sampleRate
= 44100.0f
;
137 reverb
= new TalReverb((int)sampleRate
);
139 dryParamChange
= new ParamChangeUtil(sampleRate
, 300.0f
);
140 wetParamChange
= new ParamChangeUtil(sampleRate
, 300.0f
);
142 noiseGenerator
= new NoiseGenerator(sampleRate
);
149 void process(float *sampleL
, float *sampleR
)
152 float noise
= noiseGenerator
->tickNoise() * 0.000000001f
;
157 float drysampleL
= *sampleL
;
158 float drysampleR
= *sampleR
;
160 reverb
->process(sampleL
, sampleR
);
163 float actualDryValue
= dryParamChange
->tick(dry
);
164 float wet1
= wet
* (stereoWidth
* 0.5f
+ 0.5f
);
165 float wet2
= wet
* ((1.0f
- stereoWidth
) * 0.5f
);
166 float resultL
= *sampleL
* wet1
+ *sampleR
* wet2
+ drysampleL
* actualDryValue
;
167 float resultR
= *sampleR
* wet1
+ *sampleL
* wet2
+ drysampleR
* actualDryValue
;