Loading...
Searching...
No Matches
juce_audio_basics/utilities/juce_IIRFilter.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
class IIRFilter;
//==============================================================================
class JUCE_API IIRCoefficients
{
public:
//==============================================================================
IIRCoefficients() noexcept;
IIRCoefficients (double c1, double c2, double c3,
double c4, double c5, double c6) noexcept;
IIRCoefficients (const IIRCoefficients&) noexcept;
IIRCoefficients& operator= (const IIRCoefficients&) noexcept;
~IIRCoefficients() noexcept;
//==============================================================================
static IIRCoefficients makeLowPass (double sampleRate,
double frequency) noexcept;
static IIRCoefficients makeLowPass (double sampleRate,
double frequency,
double Q) noexcept;
//==============================================================================
static IIRCoefficients makeHighPass (double sampleRate,
double frequency) noexcept;
static IIRCoefficients makeHighPass (double sampleRate,
double frequency,
double Q) noexcept;
//==============================================================================
static IIRCoefficients makeBandPass (double sampleRate, double frequency) noexcept;
static IIRCoefficients makeBandPass (double sampleRate,
double frequency,
double Q) noexcept;
//==============================================================================
static IIRCoefficients makeNotchFilter (double sampleRate, double frequency) noexcept;
static IIRCoefficients makeNotchFilter (double sampleRate,
double frequency,
double Q) noexcept;
//==============================================================================
static IIRCoefficients makeAllPass (double sampleRate, double frequency) noexcept;
static IIRCoefficients makeAllPass (double sampleRate,
double frequency,
double Q) noexcept;
//==============================================================================
static IIRCoefficients makeLowShelf (double sampleRate,
double cutOffFrequency,
double Q,
float gainFactor) noexcept;
static IIRCoefficients makeHighShelf (double sampleRate,
double cutOffFrequency,
double Q,
float gainFactor) noexcept;
static IIRCoefficients makePeakFilter (double sampleRate,
double centreFrequency,
double Q,
float gainFactor) noexcept;
//==============================================================================
float coefficients[5];
};
//==============================================================================
template <typename Mutex>
class JUCE_API IIRFilterBase
{
public:
//==============================================================================
IIRFilterBase() noexcept;
IIRFilterBase (const IIRFilterBase&) noexcept;
//==============================================================================
void makeInactive() noexcept;
void setCoefficients (const IIRCoefficients& newCoefficients) noexcept;
IIRCoefficients getCoefficients() const noexcept { return coefficients; }
//==============================================================================
void reset() noexcept;
void processSamples (float* samples, int numSamples) noexcept;
float processSingleSampleRaw (float sample) noexcept;
protected:
//==============================================================================
Mutex processLock;
IIRCoefficients coefficients;
float v1 = 0, v2 = 0;
bool active = false;
// The exact meaning of an assignment operator would be ambiguous since the filters are
// stateful. If you want to copy the coefficients, then just use setCoefficients().
IIRFilter& operator= (const IIRFilter&) = delete;
JUCE_LEAK_DETECTOR (IIRFilter)
};
class IIRFilter : public IIRFilterBase<SpinLock>
{
public:
using IIRFilterBase::IIRFilterBase;
};
class SingleThreadedIIRFilter : public IIRFilterBase<DummyCriticalSection>
{
public:
using IIRFilterBase::IIRFilterBase;
};
} // namespace juce
juce::IIRCoefficients
Definition juce_audio_basics/utilities/juce_IIRFilter.h:37
juce::IIRCoefficients::makeAllPass
static IIRCoefficients makeAllPass(double sampleRate, double frequency) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:162
juce::IIRCoefficients::makeLowPass
static IIRCoefficients makeLowPass(double sampleRate, double frequency) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:58
juce::IIRCoefficients::coefficients
float coefficients[5]
Definition juce_audio_basics/utilities/juce_IIRFilter.h:144
juce::IIRCoefficients::IIRCoefficients
IIRCoefficients() noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:28
juce::IIRCoefficients::makeNotchFilter
static IIRCoefficients makeNotchFilter(double sampleRate, double frequency) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:136
juce::IIRCoefficients::makePeakFilter
static IIRCoefficients makePeakFilter(double sampleRate, double centreFrequency, double Q, float gainFactor) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:238
juce::IIRCoefficients::makeBandPass
static IIRCoefficients makeBandPass(double sampleRate, double frequency) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:110
juce::IIRCoefficients::makeHighShelf
static IIRCoefficients makeHighShelf(double sampleRate, double cutOffFrequency, double Q, float gainFactor) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:213
juce::IIRCoefficients::makeLowShelf
static IIRCoefficients makeLowShelf(double sampleRate, double cutOffFrequency, double Q, float gainFactor) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:188
juce::IIRCoefficients::makeHighPass
static IIRCoefficients makeHighPass(double sampleRate, double frequency) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:84
juce::IIRFilterBase::IIRFilterBase
IIRFilterBase() noexcept
juce::IIRFilterBase::makeInactive
void makeInactive() noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:275
juce::IIRFilterBase::setCoefficients
void setCoefficients(const IIRCoefficients &newCoefficients) noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.cpp:282
juce::IIRFilterBase::getCoefficients
IIRCoefficients getCoefficients() const noexcept
Definition juce_audio_basics/utilities/juce_IIRFilter.h:180
juce::IIRFilter
Definition juce_audio_basics/utilities/juce_IIRFilter.h:232
juce::IIRFilter::IIRFilterBase
IIRFilterBase() noexcept
juce::SingleThreadedIIRFilter
Definition juce_audio_basics/utilities/juce_IIRFilter.h:249
juce::SingleThreadedIIRFilter::IIRFilterBase
IIRFilterBase() noexcept
juce::SpinLock
Definition juce_SpinLock.h:42