JUCE  v5.1.1-3-g1a0b28c73
JUCE API
IIR::Filter< SampleType > Class Template Reference

A processing class that can perform IIR filtering on an audio signal, using the Transposed Direct Form II digital structure. More...

#include <juce_IIRFilter.h>

Collaboration diagram for IIR::Filter< SampleType >:

Public Types

using NumericType = typename SampleTypeHelpers::ElementType< SampleType >::Type
 The NumericType is the underlying primitive type used by the SampleType (which could be either a primitive or vector) More...
 

Public Member Functions

 Filter ()
 Creates a filter. More...
 
 Filter (Coefficients< NumericType > *coefficientsToUse)
 Creates a filter with a given set of coefficients. More...
 
 Filter (const Filter &)=default
 Creates a copy of another filter. More...
 
 Filter (Filter &&)=default
 Move constructor. More...
 
void prepare (const ProcessSpec &) noexcept
 Called before processing starts. More...
 
template<typename ProcessContext >
void process (const ProcessContext &context) noexcept
 Processes as a block of samples. More...
 
SampleType JUCE_VECTOR_CALLTYPE processSample (SampleType sample) noexcept
 Processes a single sample, without any locking. More...
 
void reset ()
 Resets the filter's processing pipeline, ready to start a new stream of data. More...
 
void reset (SampleType resetToValue)
 Resets the filter's processing pipeline to a specific value. More...
 

Public Attributes

Coefficients< NumericType >::Ptr coefficients
 The coefficients of the IIR filter. More...
 

Private Member Functions

void check ()
 
void snapToZero () noexcept
 

Private Attributes

HeapBlock< SampleType > memory
 
size_t order = 0
 
SampleType * state = nullptr
 

Detailed Description

template<typename SampleType>
class IIR::Filter< SampleType >

A processing class that can perform IIR filtering on an audio signal, using the Transposed Direct Form II digital structure.

If you need a lowpass, bandpass or highpass filter with fast modulation of its cutoff frequency, you might use the class StateVariableFilter instead, which is designed to prevent artefacts at parameter changes, instead of the class Filter.

See also
Filter::Coefficients, FilterAudioSource, StateVariableFilter

Member Typedef Documentation

◆ NumericType

template<typename SampleType >
using IIR::Filter< SampleType >::NumericType = typename SampleTypeHelpers::ElementType<SampleType>::Type

The NumericType is the underlying primitive type used by the SampleType (which could be either a primitive or vector)

Constructor & Destructor Documentation

◆ Filter() [1/4]

template<typename SampleType >
IIR::Filter< SampleType >::Filter ( )

Creates a filter.

Initially the filter is inactive, so will have no effect on samples that you process with it. Use the setCoefficients() method to turn it into the type of filter needed.

◆ Filter() [2/4]

template<typename SampleType >
IIR::Filter< SampleType >::Filter ( Coefficients< NumericType > *  coefficientsToUse)

Creates a filter with a given set of coefficients.

◆ Filter() [3/4]

template<typename SampleType >
IIR::Filter< SampleType >::Filter ( const Filter< SampleType > &  )
default

Creates a copy of another filter.

◆ Filter() [4/4]

template<typename SampleType >
IIR::Filter< SampleType >::Filter ( Filter< SampleType > &&  )
default

Move constructor.

Member Function Documentation

◆ check()

template<typename SampleType >
void IIR::Filter< SampleType >::check ( )
private

◆ prepare()

template<typename SampleType >
void IIR::Filter< SampleType >::prepare ( const ProcessSpec )
noexcept

Called before processing starts.

Referenced by IIR::Filter< SampleType >::reset().

◆ process()

template<typename SampleType >
template<typename ProcessContext >
void IIR::Filter< SampleType >::process ( const ProcessContext context)
noexcept

Processes as a block of samples.

Referenced by IIR::Filter< SampleType >::reset().

◆ processSample()

template<typename SampleType >
SampleType JUCE_VECTOR_CALLTYPE IIR::Filter< SampleType >::processSample ( SampleType  sample)
noexcept

Processes a single sample, without any locking.

Use this if you need processing of a single value.

Moreover, you might need the function snapToZero after a few calls to avoid potential denormalisation issues.

Referenced by IIR::Filter< SampleType >::reset().

◆ reset() [1/2]

template<typename SampleType >
void IIR::Filter< SampleType >::reset ( )
inline

Resets the filter's processing pipeline, ready to start a new stream of data.

Note that this clears the processing state, but the type of filter and its coefficients aren't changed.

References IIR::Filter< SampleType >::check(), JUCE_VECTOR_CALLTYPE, IIR::Filter< SampleType >::prepare(), IIR::Filter< SampleType >::process(), IIR::Filter< SampleType >::processSample(), IIR::Filter< SampleType >::reset(), and IIR::Filter< SampleType >::snapToZero().

Referenced by IIR::Filter< SampleType >::reset().

◆ reset() [2/2]

template<typename SampleType >
void IIR::Filter< SampleType >::reset ( SampleType  resetToValue)

Resets the filter's processing pipeline to a specific value.

See

◆ snapToZero()

template<typename SampleType >
void IIR::Filter< SampleType >::snapToZero ( )
privatenoexcept

Member Data Documentation

◆ coefficients

template<typename SampleType >
Coefficients<NumericType>::Ptr IIR::Filter< SampleType >::coefficients

The coefficients of the IIR filter.

It's up to the called to ensure that these coefficients are modified in a thread-safe way.

If you change the order of the coefficients then you must call reset after modifying them.

Referenced by IIR::Coefficients< NumericType >::getRawCoefficients().

◆ memory

template<typename SampleType >
HeapBlock<SampleType> IIR::Filter< SampleType >::memory
private

◆ order

template<typename SampleType >
size_t IIR::Filter< SampleType >::order = 0
private

◆ state

template<typename SampleType >
SampleType* IIR::Filter< SampleType >::state = nullptr
private

The documentation for this class was generated from the following file: