32template <
typename NumericType>
34 : coefficients ({ NumericType(),
42template <
typename NumericType>
44 NumericType
a0, NumericType
a1)
50 auto a0inv =
static_cast<NumericType
> (1) /
a0;
57template <
typename NumericType>
59 NumericType
a0, NumericType
a1, NumericType
a2)
65 auto a0inv =
static_cast<NumericType
> (1) /
a0;
74template <
typename NumericType>
76 NumericType
a0, NumericType
a1, NumericType
a2, NumericType
a3)
82 auto a0inv =
static_cast<NumericType
> (1) /
a0;
93template <
typename NumericType>
95 NumericType frequency)
97 jassert (sampleRate > 0.0);
98 jassert (frequency > 0 && frequency <=
static_cast<float> (sampleRate * 0.5));
105template <
typename NumericType>
107 NumericType frequency)
109 jassert (sampleRate > 0.0);
110 jassert (frequency > 0 && frequency <=
static_cast<float> (sampleRate * 0.5));
117template <
typename NumericType>
119 NumericType frequency)
121 jassert (sampleRate > 0.0);
122 jassert (frequency > 0 && frequency <=
static_cast<float> (sampleRate * 0.5));
129template <
typename NumericType>
131 NumericType frequency)
133 return makeLowPass (sampleRate, frequency, inverseRootTwo);
136template <
typename NumericType>
138 NumericType frequency,
141 jassert (sampleRate > 0.0);
142 jassert (frequency > 0 && frequency <=
static_cast<float> (sampleRate * 0.5));
155template <
typename NumericType>
157 NumericType frequency)
159 return makeHighPass (sampleRate, frequency, inverseRootTwo);
162template <
typename NumericType>
164 NumericType frequency,
167 jassert (sampleRate > 0.0);
168 jassert (frequency > 0 && frequency <=
static_cast<float> (sampleRate * 0.5));
181template <
typename NumericType>
183 NumericType frequency)
185 return makeBandPass (sampleRate, frequency, inverseRootTwo);
188template <
typename NumericType>
190 NumericType frequency,
193 jassert (sampleRate > 0.0);
194 jassert (frequency > 0 && frequency <=
static_cast<float> (sampleRate * 0.5));
208template <
typename NumericType>
210 NumericType frequency)
212 return makeNotch (sampleRate, frequency, inverseRootTwo);
215template <
typename NumericType>
217 NumericType frequency,
220 jassert (sampleRate > 0.0);
221 jassert (frequency > 0 && frequency <=
static_cast<float> (sampleRate * 0.5));
234template <
typename NumericType>
236 NumericType frequency)
238 return makeAllPass (sampleRate, frequency, inverseRootTwo);
241template <
typename NumericType>
243 NumericType frequency,
246 jassert (sampleRate > 0);
247 jassert (frequency > 0 && frequency <= sampleRate * 0.5);
260template <
typename NumericType>
266 jassert (sampleRate > 0.0);
270 auto A = jmax (
static_cast<NumericType
> (0.0), std::sqrt (
gainFactor));
275 auto beta = std::sin (
omega) * std::sqrt (A) /
Q;
286template <
typename NumericType>
292 jassert (sampleRate > 0);
296 auto A = jmax (
static_cast<NumericType
> (0.0), std::sqrt (
gainFactor));
301 auto beta = std::sin (
omega) * std::sqrt (A) /
Q;
312template <
typename NumericType>
314 NumericType frequency,
318 jassert (sampleRate > 0);
319 jassert (frequency > 0 && frequency <=
static_cast<NumericType
> (sampleRate * 0.5));
323 auto A = jmax (
static_cast<NumericType
> (0.0), std::sqrt (
gainFactor));
325 auto alpha = std::sin (
omega) / (
Q * 2);
326 auto c2 = -2 * std::cos (
omega);
336template <
typename NumericType>
339 return (
static_cast<size_t> (coefficients.size()) - 1) / 2;
342template <
typename NumericType>
346 const auto order = getFilterOrder();
349 jassert (frequency >= 0 && frequency <= sampleRate * 0.5);
354 for (
size_t n = 0; n <= order; ++n)
363 for (
size_t n = order + 1; n <= 2 * order; ++n)
372template <
typename NumericType>
374 size_t numSamples,
double sampleRate)
const noexcept
377 const auto order = getFilterOrder();
380 jassert (order >= 0);
382 for (
size_t i = 0; i < numSamples; ++i)
389 for (
size_t n = 0; n <= order; ++n)
398 for (
size_t n = order + 1; n <= 2 * order; ++n)
408template <
typename NumericType>
412 const auto order = getFilterOrder();
415 jassert (frequency >= 0 && frequency <= sampleRate * 0.5);
420 for (
size_t n = 0; n <= order; ++n)
429 for (
size_t n = order + 1; n <= 2 * order; ++n)
438template <
typename NumericType>
440 size_t numSamples,
double sampleRate)
const noexcept
442 jassert (sampleRate > 0);
445 const auto order = getFilterOrder();
449 jassert (order >= 0);
451 for (
size_t i = 0; i < numSamples; ++i)
458 for (
size_t n = 0; n <= order; ++n)
467 for (
size_t n = order + 1; n <= 2 * order; ++n)
ElementType * begin() noexcept
void add(const ElementType &newElement)
static Ptr makeNotch(double sampleRate, NumericType frequency)
static Ptr makeHighShelf(double sampleRate, NumericType cutOffFrequency, NumericType Q, NumericType gainFactor)
void getMagnitudeForFrequencyArray(const double *frequencies, double *magnitudes, size_t numSamples, double sampleRate) const noexcept
double getMagnitudeForFrequency(double frequency, double sampleRate) const noexcept
static Ptr makeAllPass(double sampleRate, NumericType frequency)
static Ptr makeFirstOrderHighPass(double sampleRate, NumericType frequency)
void getPhaseForFrequencyArray(double *frequencies, double *phases, size_t numSamples, double sampleRate) const noexcept
static Ptr makeFirstOrderAllPass(double sampleRate, NumericType frequency)
static Ptr makePeakFilter(double sampleRate, NumericType centreFrequency, NumericType Q, NumericType gainFactor)
static Ptr makeLowPass(double sampleRate, NumericType frequency)
double getPhaseForFrequency(double frequency, double sampleRate) const noexcept
size_t getFilterOrder() const noexcept
static Ptr makeLowShelf(double sampleRate, NumericType cutOffFrequency, NumericType Q, NumericType gainFactor)
static Ptr makeBandPass(double sampleRate, NumericType frequency)
static Ptr makeHighPass(double sampleRate, NumericType frequency)
static Ptr makeFirstOrderLowPass(double sampleRate, NumericType frequency)