dsp::FIR::Filter< SampleType > Class Template Reference

A processing class that can perform FIR filtering on an audio signal, in the time domain. More...

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 ()
 This will create a filter which will produce silence. More...
 
 Filter (Coefficients< NumericType > *coefficientsToUse)
 Creates a filter with a given set of coefficients. More...
 
 Filter (const Filter &)=default
 
 Filter (Filter &&)=default
 
Filteroperator= (const Filter &)=default
 
Filteroperator= (Filter &&)=default
 
void prepare (const ProcessSpec &spec) noexcept
 Prepare this filter for processing. More...
 
void reset ()
 Resets the filter's processing pipeline, ready to start a new stream of data. 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...
 

Public Attributes

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

Detailed Description

template<typename SampleType>
class dsp::FIR::Filter< SampleType >

A processing class that can perform FIR filtering on an audio signal, in the time domain.

Using FIRFilter is fast enough for FIRCoefficients with a size lower than 128 samples. For longer filters, it might be more efficient to use the class Convolution instead, which does the same processing in the frequency domain thanks to FFT.

See also
FIRFilter::Coefficients, Convolution, FFT

Member Typedef Documentation

◆ NumericType

template<typename SampleType >
using dsp::FIR::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 >
dsp::FIR::Filter< SampleType >::Filter ( )

This will create a filter which will produce silence.

References dsp::FIR::Filter< SampleType >::reset().

Referenced by dsp::FIR::Filter< SampleType >::Filter().

◆ Filter() [2/4]

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

◆ Filter() [3/4]

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

◆ Filter() [4/4]

template<typename SampleType >
dsp::FIR::Filter< SampleType >::Filter ( Filter< SampleType > &&  )
default

Member Function Documentation

◆ operator=() [1/2]

template<typename SampleType >
Filter& dsp::FIR::Filter< SampleType >::operator= ( const Filter< SampleType > &  )
default

◆ operator=() [2/2]

template<typename SampleType >
Filter& dsp::FIR::Filter< SampleType >::operator= ( Filter< SampleType > &&  )
default

◆ prepare()

template<typename SampleType >
void dsp::FIR::Filter< SampleType >::prepare ( const ProcessSpec spec)
noexcept

Prepare this filter for processing.

References ignoreUnused(), jassert, and dsp::FIR::Filter< SampleType >::reset().

◆ reset()

template<typename SampleType >
void dsp::FIR::Filter< SampleType >::reset ( )

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. To disable the filter, call setEnabled (false).

References dsp::FIR::Filter< SampleType >::coefficients, HeapBlock< ElementType, throwOnFailure >::getData(), jmax(), HeapBlock< ElementType, throwOnFailure >::malloc(), and snapPointerToAlignment().

Referenced by dsp::FIR::Filter< SampleType >::Filter(), dsp::FIR::Filter< SampleType >::prepare(), and dsp::FIR::Filter< SampleType >::processSample().

◆ process()

template<typename SampleType >
template<typename ProcessContext >
void dsp::FIR::Filter< SampleType >::process ( const ProcessContext &  context)
noexcept

Processes as a block of samples.

References jassert.

◆ processSample()

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

Processes a single sample, without any locking.

Use this if you need processing of a single value.

References jassert, JUCE_LEAK_DETECTOR, and dsp::FIR::Filter< SampleType >::reset().

Member Data Documentation

◆ coefficients

template<typename SampleType >
Coefficients<NumericType>::Ptr dsp::FIR::Filter< SampleType >::coefficients

The coefficients of the FIR 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 dsp::FIR::Coefficients< NumericType >::Coefficients(), dsp::FIR::Coefficients< NumericType >::getFilterOrder(), dsp::FIR::Coefficients< NumericType >::getRawCoefficients(), and dsp::FIR::Filter< SampleType >::reset().


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