79 gain = isFrozen (
newParams.freezeMode) ? 0.0f : 0.015f;
90 jassert (sampleRate > 0);
92 static const short combTunings[] = { 1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617 };
97 for (
int i = 0; i < numCombs; ++i)
103 for (
int i = 0; i < numAllPasses; ++i)
120 for (
int j = 0;
j < numChannels; ++
j)
122 for (
int i = 0; i < numCombs; ++i)
125 for (
int i = 0; i < numAllPasses; ++i)
126 allPass[
j][i].clear();
132 void processStereo (
float*
const left,
float*
const right,
const int numSamples)
noexcept
134 jassert (left !=
nullptr && right !=
nullptr);
136 for (
int i = 0; i < numSamples; ++i)
138 const float input = (left[i] + right[i]) * gain;
144 for (
int j = 0;
j < numCombs; ++
j)
150 for (
int j = 0;
j < numAllPasses; ++
j)
170 for (
int i = 0; i < numSamples; ++i)
172 const float input =
samples[i] * gain;
178 for (
int j = 0;
j < numCombs; ++
j)
181 for (
int j = 0;
j < numAllPasses; ++
j)
182 output = allPass[0][
j].process (output);
193 static bool isFrozen (
const float freezeMode)
noexcept {
return freezeMode >= 0.5f; }
195 void updateDamping() noexcept
197 const float roomScaleFactor = 0.28f;
198 const float roomOffset = 0.7f;
199 const float dampScaleFactor = 0.4f;
202 setDamping (0.0f, 1.0f);
204 setDamping (parameters.
damping * dampScaleFactor,
205 parameters.
roomSize * roomScaleFactor + roomOffset);
208 void setDamping (
const float dampingToUse,
const float roomSizeToUse)
noexcept
218 CombFilter() noexcept {}
220 void setSize (
const int size)
222 if (size != bufferSize)
225 buffer.malloc (size);
232 void clear() noexcept
235 buffer.clear ((
size_t) bufferSize);
238 float process (
const float input,
const float damp,
const float feedbackLevel)
noexcept
240 const float output = buffer[bufferIndex];
241 last = (output * (1.0f - damp)) + (last * damp);
242 JUCE_UNDENORMALISE (last);
244 float temp = input + (last * feedbackLevel);
245 JUCE_UNDENORMALISE (temp);
246 buffer[bufferIndex] = temp;
247 bufferIndex = (bufferIndex + 1) % bufferSize;
252 HeapBlock<float> buffer;
253 int bufferSize = 0, bufferIndex = 0;
256 JUCE_DECLARE_NON_COPYABLE (CombFilter)
263 AllPassFilter() noexcept {}
265 void setSize (
const int size)
267 if (size != bufferSize)
270 buffer.malloc (size);
277 void clear() noexcept
279 buffer.clear ((
size_t) bufferSize);
282 float process (
const float input)
noexcept
284 const float bufferedValue = buffer [bufferIndex];
285 float temp = input + (bufferedValue * 0.5f);
286 JUCE_UNDENORMALISE (temp);
287 buffer [bufferIndex] = temp;
288 bufferIndex = (bufferIndex + 1) % bufferSize;
289 return bufferedValue - input;
293 HeapBlock<float> buffer;
294 int bufferSize = 0, bufferIndex = 0;
296 JUCE_DECLARE_NON_COPYABLE (AllPassFilter)
300 enum { numCombs = 8, numAllPasses = 4, numChannels = 2 };
302 Parameters parameters;
305 CombFilter comb [numChannels][numCombs];
306 AllPassFilter allPass [numChannels][numAllPasses];
308 SmoothedValue<float> damping, feedback, dryGain, wetGain1, wetGain2;
310 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Reverb)