35 template <
typename NumericType>
48 static std::array<NumericType, 6>
makeLowPass (
double sampleRate, NumericType frequency);
51 static std::array<NumericType, 6>
makeLowPass (
double sampleRate, NumericType frequency, NumericType Q);
54 static std::array<NumericType, 6>
makeHighPass (
double sampleRate, NumericType frequency);
57 static std::array<NumericType, 6>
makeHighPass (
double sampleRate, NumericType frequency, NumericType Q);
60 static std::array<NumericType, 6>
makeBandPass (
double sampleRate, NumericType frequency);
63 static std::array<NumericType, 6>
makeBandPass (
double sampleRate, NumericType frequency, NumericType Q);
66 static std::array<NumericType, 6>
makeNotch (
double sampleRate, NumericType frequency);
69 static std::array<NumericType, 6>
makeNotch (
double sampleRate, NumericType frequency, NumericType Q);
72 static std::array<NumericType, 6>
makeAllPass (
double sampleRate, NumericType frequency);
75 static std::array<NumericType, 6>
makeAllPass (
double sampleRate, NumericType frequency, NumericType Q);
83 static std::array<NumericType, 6>
makeLowShelf (
double sampleRate,
84 NumericType cutOffFrequency,
86 NumericType gainFactor);
94 static std::array<NumericType, 6>
makeHighShelf (
double sampleRate,
95 NumericType cutOffFrequency,
97 NumericType gainFactor);
106 static std::array<NumericType, 6>
makePeakFilter (
double sampleRate,
107 NumericType centreFrequency,
109 NumericType gainFactor);
113 static constexpr NumericType inverseRootTwo =
static_cast<NumericType
> (0.70710678118654752440L);
122 template <
typename NumericType>
133 NumericType a0, NumericType a1);
135 Coefficients (NumericType b0, NumericType b1, NumericType b2,
136 NumericType a0, NumericType a1, NumericType a2);
138 Coefficients (NumericType b0, NumericType b1, NumericType b2, NumericType b3,
139 NumericType a0, NumericType a1, NumericType a2, NumericType a3);
147 template <
size_t Num>
148 explicit Coefficients (
const std::array<NumericType, Num>& values) { assignImpl<Num> (values.data()); }
151 template <
size_t Num>
152 Coefficients& operator= (
const std::array<NumericType, Num>& values) {
return assignImpl<Num> (values.data()); }
171 static Ptr makeLowPass (
double sampleRate, NumericType frequency);
174 static Ptr makeLowPass (
double sampleRate, NumericType frequency, NumericType Q);
181 static Ptr makeHighPass (
double sampleRate, NumericType frequency, NumericType Q);
188 static Ptr makeBandPass (
double sampleRate, NumericType frequency, NumericType Q);
192 static Ptr makeNotch (
double sampleRate, NumericType frequency);
195 static Ptr makeNotch (
double sampleRate, NumericType frequency, NumericType Q);
199 static Ptr makeAllPass (
double sampleRate, NumericType frequency);
202 static Ptr makeAllPass (
double sampleRate, NumericType frequency, NumericType Q);
211 static Ptr makeLowShelf (
double sampleRate, NumericType cutOffFrequency,
212 NumericType Q, NumericType gainFactor);
221 NumericType Q, NumericType gainFactor);
231 NumericType Q, NumericType gainFactor);
246 size_t numSamples,
double sampleRate) const noexcept;
257 size_t numSamples,
double sampleRate) const noexcept;
274 template <
size_t Num>
277 template <
size_t Num>
278 Coefficients& assign (
const NumericType (& values)[Num]) {
return assignImpl<Num> (values); }
295 template <
typename SampleType>
302 using NumericType =
typename SampleTypeHelpers::ElementType<SampleType>::Type;
344 void reset (SampleType resetToValue);
351 template <
typename ProcessContext>
352 void process (
const ProcessContext& context)
noexcept
354 if (context.isBypassed)
355 processInternal<ProcessContext, true> (context);
357 processInternal<ProcessContext, false> (context);
359 #if JUCE_DSP_ENABLE_SNAP_TO_ZERO
371 SampleType JUCE_VECTOR_CALLTYPE
processSample (SampleType sample)
noexcept;
384 template <typename ProcessContext,
bool isBypassed>
385 void processInternal (const ProcessContext& context) noexcept;
389 SampleType* state =
nullptr;
392 JUCE_LEAK_DETECTOR (
Filter)
void prepare(const ProcessSpec &) noexcept
CoefficientsPtr coefficients
void snapToZero() noexcept
SampleType JUCE_VECTOR_CALLTYPE processSample(SampleType sample) noexcept
typename Coefficients< NumericType >::Ptr CoefficientsPtr
typename SampleTypeHelpers::ElementType< SampleType >::Type NumericType
void process(const ProcessContext &context) noexcept
static std::array< NumericType, 6 > makeHighPass(double sampleRate, NumericType frequency)
static std::array< NumericType, 6 > makePeakFilter(double sampleRate, NumericType centreFrequency, NumericType Q, NumericType gainFactor)
static std::array< NumericType, 6 > makeBandPass(double sampleRate, NumericType frequency)
static std::array< NumericType, 4 > makeFirstOrderHighPass(double sampleRate, NumericType frequency)
static std::array< NumericType, 6 > makeLowPass(double sampleRate, NumericType frequency)
static std::array< NumericType, 6 > makeLowShelf(double sampleRate, NumericType cutOffFrequency, NumericType Q, NumericType gainFactor)
static std::array< NumericType, 4 > makeFirstOrderLowPass(double sampleRate, NumericType frequency)
static std::array< NumericType, 4 > makeFirstOrderAllPass(double sampleRate, NumericType frequency)
static std::array< NumericType, 6 > makeAllPass(double sampleRate, NumericType frequency)
static std::array< NumericType, 6 > makeHighShelf(double sampleRate, NumericType cutOffFrequency, NumericType Q, NumericType gainFactor)
static std::array< NumericType, 6 > makeNotch(double sampleRate, NumericType frequency)
static Ptr makeLowShelf(double sampleRate, NumericType cutOffFrequency, NumericType Q, NumericType gainFactor)
const NumericType * getRawCoefficients() const noexcept
Coefficients(const std::array< NumericType, Num > &values)
static Ptr makeFirstOrderHighPass(double sampleRate, NumericType frequency)
static Ptr makeHighPass(double sampleRate, NumericType frequency)
ReferenceCountedObjectPtr< Coefficients > Ptr
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
static Ptr makeLowPass(double sampleRate, NumericType frequency)
double getMagnitudeForFrequency(double frequency, double sampleRate) const noexcept
static Ptr makePeakFilter(double sampleRate, NumericType centreFrequency, NumericType Q, NumericType gainFactor)
void getPhaseForFrequencyArray(double *frequencies, double *phases, size_t numSamples, double sampleRate) const noexcept
static Ptr makeAllPass(double sampleRate, NumericType frequency)
NumericType * getRawCoefficients() noexcept
static Ptr makeBandPass(double sampleRate, NumericType frequency)
double getPhaseForFrequency(double frequency, double sampleRate) const noexcept
static Ptr makeNotch(double sampleRate, NumericType frequency)
size_t getFilterOrder() const noexcept
static Ptr makeFirstOrderLowPass(double sampleRate, NumericType frequency)
static Ptr makeFirstOrderAllPass(double sampleRate, NumericType frequency)
Array< NumericType > coefficients