35 memcpy (coefficients, other.coefficients, sizeof (coefficients));
40 memcpy (coefficients, other.coefficients, sizeof (coefficients));
45 double c4,
double c5,
double c6)
noexcept
49 coefficients[0] = (float) (c1 * a);
50 coefficients[1] = (float) (c2 * a);
51 coefficients[2] = (float) (c3 * a);
52 coefficients[3] = (float) (c5 * a);
53 coefficients[4] = (float) (c6 * a);
57 double frequency)
noexcept
66 jassert (sampleRate > 0.0);
67 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
71 auto nSquared = n * n;
72 auto c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
78 c1 * 2.0 * (1.0 - nSquared),
79 c1 * (1.0 - 1.0 / Q * n + nSquared));
83 double frequency)
noexcept
85 return makeHighPass (sampleRate, frequency, 1.0 / std::sqrt(2.0));
92 jassert (sampleRate > 0.0);
93 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
97 auto nSquared = n * n;
98 auto c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
104 c1 * 2.0 * (nSquared - 1.0),
105 c1 * (1.0 - 1.0 / Q * n + nSquared));
109 double frequency)
noexcept
118 jassert (sampleRate > 0.0);
119 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
123 auto nSquared = n * n;
124 auto c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
130 c1 * 2.0 * (1.0 - nSquared),
131 c1 * (1.0 - 1.0 / Q * n + nSquared));
135 double frequency)
noexcept
144 jassert (sampleRate > 0.0);
145 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
149 auto nSquared = n * n;
150 auto c1 = 1.0 / (1.0 + n / Q + nSquared);
153 2.0 * c1 * (1.0 - nSquared),
154 c1 * (1.0 + nSquared),
156 c1 * 2.0 * (1.0 - nSquared),
157 c1 * (1.0 - n / Q + nSquared));
161 double frequency)
noexcept
170 jassert (sampleRate > 0.0);
171 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
175 auto nSquared = n * n;
176 auto c1 = 1.0 / (1.0 + 1.0 / Q * n + nSquared);
179 c1 * 2.0 * (1.0 - nSquared),
182 c1 * 2.0 * (1.0 - nSquared),
183 c1 * (1.0 - n / Q + nSquared));
187 double cutOffFrequency,
189 float gainFactor)
noexcept
191 jassert (sampleRate > 0.0);
192 jassert (cutOffFrequency > 0.0 && cutOffFrequency <= sampleRate * 0.5);
195 auto A = jmax (0.0f, std::sqrt (gainFactor));
196 auto aminus1 = A - 1.0;
197 auto aplus1 = A + 1.0;
199 auto coso = std::cos (omega);
200 auto beta = std::sin (omega) * std::sqrt (A) / Q;
201 auto aminus1TimesCoso = aminus1 * coso;
204 A * 2.0 * (aminus1 - aplus1 * coso),
205 A * (aplus1 - aminus1TimesCoso - beta),
206 aplus1 + aminus1TimesCoso + beta,
207 -2.0 * (aminus1 + aplus1 * coso),
208 aplus1 + aminus1TimesCoso - beta);
212 double cutOffFrequency,
214 float gainFactor)
noexcept
216 jassert (sampleRate > 0.0);
217 jassert (cutOffFrequency > 0.0 && cutOffFrequency <= sampleRate * 0.5);
220 auto A = jmax (0.0f, std::sqrt (gainFactor));
221 auto aminus1 = A - 1.0;
222 auto aplus1 = A + 1.0;
224 auto coso = std::cos (omega);
225 auto beta = std::sin (omega) * std::sqrt (A) / Q;
226 auto aminus1TimesCoso = aminus1 * coso;
229 A * -2.0 * (aminus1 + aplus1 * coso),
230 A * (aplus1 + aminus1TimesCoso - beta),
231 aplus1 - aminus1TimesCoso + beta,
232 2.0 * (aminus1 - aplus1 * coso),
233 aplus1 - aminus1TimesCoso - beta);
239 float gainFactor)
noexcept
241 jassert (sampleRate > 0.0);
242 jassert (frequency > 0.0 && frequency <= sampleRate * 0.5);
245 auto A = jmax (0.0f, std::sqrt (gainFactor));
247 auto alpha = 0.5 * std::sin (omega) / Q;
248 auto c2 = -2.0 * std::cos (omega);
249 auto alphaTimesA = alpha * A;
250 auto alphaOverA = alpha / A;
268 coefficients = other.coefficients;
285 coefficients = newCoefficients;
298 auto out = coefficients.coefficients[0] * in + v1;
300 JUCE_SNAP_TO_ZERO (out);
302 v1 = coefficients.coefficients[1] * in - coefficients.coefficients[3] * out + v2;
303 v2 = coefficients.coefficients[2] * in - coefficients.coefficients[4] * out;
314 auto c0 = coefficients.coefficients[0];
315 auto c1 = coefficients.coefficients[1];
316 auto c2 = coefficients.coefficients[2];
317 auto c3 = coefficients.coefficients[3];
318 auto c4 = coefficients.coefficients[4];
319 auto lv1 = v1, lv2 = v2;
321 for (
int i = 0; i < numSamples; ++i)
323 auto in = samples[i];
324 auto out = c0 * in + lv1;
327 lv1 = c1 * in - c3 * out + lv2;
328 lv2 = c2 * in - c4 * out;
331 JUCE_SNAP_TO_ZERO (lv1); v1 = lv1;
332 JUCE_SNAP_TO_ZERO (lv2); v2 = lv2;
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
float processSingleSampleRaw(float sample) noexcept
void processSamples(float *samples, int numSamples) noexcept
void setCoefficients(const IIRCoefficients &newCoefficients) noexcept
void makeInactive() noexcept