83 gain = isFrozen (
newParams.freezeMode) ? 0.0f : 0.015f;
94 jassert (sampleRate > 0);
96 static const short combTunings[] = { 1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617 };
101 for (
int i = 0; i < numCombs; ++i)
107 for (
int i = 0; i < numAllPasses; ++i)
124 for (
int j = 0;
j < numChannels; ++
j)
126 for (
int i = 0; i < numCombs; ++i)
129 for (
int i = 0; i < numAllPasses; ++i)
130 allPass[
j][i].clear();
136 void processStereo (
float*
const left,
float*
const right,
const int numSamples)
noexcept
138 jassert (left !=
nullptr && right !=
nullptr);
140 for (
int i = 0; i < numSamples; ++i)
142 const float input = (left[i] + right[i]) * gain;
148 for (
int j = 0;
j < numCombs; ++
j)
154 for (
int j = 0;
j < numAllPasses; ++
j)
174 for (
int i = 0; i < numSamples; ++i)
176 const float input =
samples[i] * gain;
182 for (
int j = 0;
j < numCombs; ++
j)
185 for (
int j = 0;
j < numAllPasses; ++
j)
186 output = allPass[0][
j].process (output);
197 static bool isFrozen (
const float freezeMode)
noexcept {
return freezeMode >= 0.5f; }
199 void updateDamping() noexcept
201 const float roomScaleFactor = 0.28f;
202 const float roomOffset = 0.7f;
203 const float dampScaleFactor = 0.4f;
206 setDamping (0.0f, 1.0f);
208 setDamping (parameters.
damping * dampScaleFactor,
209 parameters.
roomSize * roomScaleFactor + roomOffset);
212 void setDamping (
const float dampingToUse,
const float roomSizeToUse)
noexcept
222 CombFilter() noexcept {}
224 void setSize (
const int size)
226 if (size != bufferSize)
229 buffer.malloc (size);
236 void clear() noexcept
239 buffer.clear ((
size_t) bufferSize);
242 float process (
const float input,
const float damp,
const float feedbackLevel)
noexcept
244 const float output = buffer[bufferIndex];
245 last = (output * (1.0f - damp)) + (last * damp);
246 JUCE_UNDENORMALISE (last);
248 float temp = input + (last * feedbackLevel);
249 JUCE_UNDENORMALISE (temp);
250 buffer[bufferIndex] = temp;
251 bufferIndex = (bufferIndex + 1) % bufferSize;
256 HeapBlock<float> buffer;
257 int bufferSize = 0, bufferIndex = 0;
260 JUCE_DECLARE_NON_COPYABLE (CombFilter)
267 AllPassFilter() noexcept {}
269 void setSize (
const int size)
271 if (size != bufferSize)
274 buffer.malloc (size);
281 void clear() noexcept
283 buffer.clear ((
size_t) bufferSize);
286 float process (
const float input)
noexcept
288 const float bufferedValue = buffer [bufferIndex];
289 float temp = input + (bufferedValue * 0.5f);
290 JUCE_UNDENORMALISE (temp);
291 buffer [bufferIndex] = temp;
292 bufferIndex = (bufferIndex + 1) % bufferSize;
293 return bufferedValue - input;
297 HeapBlock<float> buffer;
298 int bufferSize = 0, bufferIndex = 0;
300 JUCE_DECLARE_NON_COPYABLE (AllPassFilter)
304 enum { numCombs = 8, numAllPasses = 4, numChannels = 2 };
306 Parameters parameters;
309 CombFilter comb [numChannels][numCombs];
310 AllPassFilter allPass [numChannels][numAllPasses];
312 SmoothedValue<float> damping, feedback, dryGain, wetGain1, wetGain2;
314 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Reverb)
Holds a resizable array of primitive or copy-by-value objects.
Performs a simple reverb effect on a stream of audio data.
void processMono(float *const samples, const int numSamples) noexcept
Applies the reverb to a single mono channel of audio data.
void reset()
Clears the reverb's buffers.
void processStereo(float *const left, float *const right, const int numSamples) noexcept
Applies the reverb to two stereo channels of audio data.
void setParameters(const Parameters &newParams)
Applies a new set of parameters to the reverb.
const Parameters & getParameters() const noexcept
Returns the reverb's current parameters.
void setSampleRate(const double sampleRate)
Sets the sample rate that will be used for the reverb.
FloatType getNextValue() noexcept
Compute the next value.
void reset(double sampleRate, double rampLengthInSeconds) noexcept
Reset to a new sample rate and ramp length.
void setTargetValue(FloatType newValue) noexcept
Set the next value to ramp towards.
float roomSize
Room size, 0 to 1.0, where 1.0 is big, 0 is small.
float width
Reverb width, 0 to 1.0, where 1.0 is very wide.
float dryLevel
Dry level, 0 to 1.0.
float wetLevel
Wet level, 0 to 1.0.
float freezeMode
Freeze mode - values < 0.5 are "normal" mode, values > 0.5 put the reverb into a continuous feedback ...
float damping
Damping, 0 to 1.0, where 0 is not damped, 1.0 is fully damped.
Holds the parameters being used by a Reverb object.