26constexpr auto minimumDecibels = -300.0f;
47 double c4,
double c5,
double c6)
noexcept
49 const auto a = 1.0 / c4;
59 double frequency)
noexcept
68 jassert (sampleRate > 0.0);
69 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
73 const auto nSquared = n * n;
74 const auto c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
80 c1 * 2.0 * (1.0 - nSquared),
81 c1 * (1.0 - 1.0 / Q * n + nSquared));
85 double frequency)
noexcept
87 return makeHighPass (sampleRate, frequency, 1.0 / std::sqrt (2.0));
94 jassert (sampleRate > 0.0);
95 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
99 const auto nSquared = n * n;
100 const auto c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
106 c1 * 2.0 * (nSquared - 1.0),
107 c1 * (1.0 - 1.0 / Q * n + nSquared));
111 double frequency)
noexcept
120 jassert (sampleRate > 0.0);
121 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
125 const auto nSquared = n * n;
126 const auto c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
132 c1 * 2.0 * (1.0 - nSquared),
133 c1 * (1.0 - 1.0 / Q * n + nSquared));
137 double frequency)
noexcept
146 jassert (sampleRate > 0.0);
147 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
151 const auto nSquared = n * n;
152 const auto c1 = 1.0 / (1.0 + n / Q + nSquared);
155 2.0 * c1 * (1.0 - nSquared),
156 c1 * (1.0 + nSquared),
158 c1 * 2.0 * (1.0 - nSquared),
159 c1 * (1.0 - n / Q + nSquared));
163 double frequency)
noexcept
172 jassert (sampleRate > 0.0);
173 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
177 const auto nSquared = n * n;
178 const auto c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
181 c1 * 2.0 * (1.0 - nSquared),
184 c1 * 2.0 * (1.0 - nSquared),
185 c1 * (1.0 - n / Q + nSquared));
189 double cutOffFrequency,
191 float gainFactor)
noexcept
193 jassert (sampleRate > 0.0);
194 jassert (cutOffFrequency > 0.0 && cutOffFrequency <= sampleRate * 0.5);
198 const auto aminus1 = A - 1.0;
199 const auto aplus1 = A + 1.0;
201 const auto coso = std::cos (omega);
202 const auto beta = std::sin (omega) * std::sqrt (A) / Q;
203 const auto aminus1TimesCoso = aminus1 * coso;
206 A * 2.0 * (aminus1 - aplus1 * coso),
207 A * (aplus1 - aminus1TimesCoso - beta),
208 aplus1 + aminus1TimesCoso + beta,
209 -2.0 * (aminus1 + aplus1 * coso),
210 aplus1 + aminus1TimesCoso - beta);
214 double cutOffFrequency,
216 float gainFactor)
noexcept
218 jassert (sampleRate > 0.0);
219 jassert (cutOffFrequency > 0.0 && cutOffFrequency <= sampleRate * 0.5);
223 const auto aminus1 = A - 1.0;
224 const auto aplus1 = A + 1.0;
226 const auto coso = std::cos (omega);
227 const auto beta = std::sin (omega) * std::sqrt (A) / Q;
228 const auto aminus1TimesCoso = aminus1 * coso;
231 A * -2.0 * (aminus1 + aplus1 * coso),
232 A * (aplus1 + aminus1TimesCoso - beta),
233 aplus1 - aminus1TimesCoso + beta,
234 2.0 * (aminus1 - aplus1 * coso),
235 aplus1 - aminus1TimesCoso - beta);
241 float gainFactor)
noexcept
243 jassert (sampleRate > 0.0);
244 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
249 const auto alpha = 0.5 * std::sin (omega) / Q;
250 const auto c2 = -2.0 * std::cos (omega);
251 const auto alphaTimesA = alpha * A;
252 const auto alphaOverA = alpha / A;
263template <
typename Mutex>
266template <typename Mutex>
269 const typename Mutex::ScopedLockType sl (other.processLock);
270 coefficients = other.coefficients;
274template <
typename Mutex>
277 const typename Mutex::ScopedLockType sl (processLock);
281template <
typename Mutex>
284 const typename Mutex::ScopedLockType sl (processLock);
285 coefficients = newCoefficients;
290template <
typename Mutex>
293 const typename Mutex::ScopedLockType sl (processLock);
297template <
typename Mutex>
300 auto out = coefficients.coefficients[0] * in + v1;
302 JUCE_SNAP_TO_ZERO (out);
304 v1 = coefficients.coefficients[1] * in - coefficients.coefficients[3] * out + v2;
305 v2 = coefficients.coefficients[2] * in - coefficients.coefficients[4] * out;
310template <
typename Mutex>
313 const typename Mutex::ScopedLockType sl (processLock);
317 auto c0 = coefficients.coefficients[0];
318 auto c1 = coefficients.coefficients[1];
319 auto c2 = coefficients.coefficients[2];
320 auto c3 = coefficients.coefficients[3];
321 auto c4 = coefficients.coefficients[4];
322 auto lv1 = v1, lv2 = v2;
324 for (
int i = 0; i < numSamples; ++i)
326 auto in = samples[i];
327 auto out = c0 * in + lv1;
330 lv1 = c1 * in - c3 * out + lv2;
331 lv2 = c2 * in - c4 * out;
334 JUCE_SNAP_TO_ZERO (lv1); v1 = lv1;
335 JUCE_SNAP_TO_ZERO (lv2); v2 = lv2;
static Type gainWithLowerBound(Type gain, Type lowerBoundDb)
static IIRCoefficients makeAllPass(double sampleRate, double frequency) noexcept
IIRCoefficients & operator=(const IIRCoefficients &) noexcept
static IIRCoefficients makeLowPass(double sampleRate, double frequency) noexcept
IIRCoefficients() noexcept
static IIRCoefficients makeNotchFilter(double sampleRate, double frequency) noexcept
static IIRCoefficients makePeakFilter(double sampleRate, double centreFrequency, double Q, float gainFactor) noexcept
~IIRCoefficients() noexcept
static IIRCoefficients makeBandPass(double sampleRate, double frequency) noexcept
static IIRCoefficients makeHighShelf(double sampleRate, double cutOffFrequency, double Q, float gainFactor) noexcept
static IIRCoefficients makeLowShelf(double sampleRate, double cutOffFrequency, double Q, float gainFactor) noexcept
static IIRCoefficients makeHighPass(double sampleRate, double frequency) noexcept
void makeInactive() noexcept
float processSingleSampleRaw(float sample) noexcept
void setCoefficients(const IIRCoefficients &newCoefficients) noexcept
void processSamples(float *samples, int numSamples) noexcept
static constexpr FloatType twoPi
static constexpr FloatType sqrt2
static constexpr FloatType pi