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

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

#include <juce_FIRFilter.h>

Collaboration diagram for FIR::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 ()
 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
 Creates a copy of another filter. More...
 
 Filter (Filter &&)=default
 Creates a copy of another filter. More...
 
Filteroperator= (const Filter &)=default
 Assignment operator. More...
 
Filteroperator= (Filter &&)=default
 Assignment operator. More...
 
void prepare (const ProcessSpec &spec) noexcept
 Prepare this filter for processing. 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...
 

Public Attributes

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

Private Member Functions

void check ()
 

Static Private Member Functions

static SampleType JUCE_VECTOR_CALLTYPE processSingleSample (SampleType sample, SampleType *buf, const NumericType *fir, size_t m, size_t &p) noexcept
 

Private Attributes

SampleType * fifo = nullptr
 
HeapBlock< SampleType > memory
 
size_t pos = 0
 
size_t size = 0
 

Detailed Description

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

This will create a filter which will produce silence.

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

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

◆ Filter() [2/4]

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

Creates a filter with a given set of coefficients.

References FIR::Filter< SampleType >::Filter(), FIR::Filter< SampleType >::operator=(), and FIR::Filter< SampleType >::reset().

◆ Filter() [3/4]

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

Creates a copy of another filter.

◆ Filter() [4/4]

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

Creates a copy of another filter.

Member Function Documentation

◆ check()

template<typename SampleType >
void FIR::Filter< SampleType >::check ( )
inlineprivate

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

Assignment operator.

◆ prepare()

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

Prepare this filter for processing.

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

◆ process()

template<typename SampleType >
template<typename ProcessContext >
void FIR::Filter< SampleType >::process ( const ProcessContext context)
inlinenoexcept

◆ processSample()

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

Processes a single sample, without any locking.

Use this if you need processing of a single value.

References FIR::Filter< SampleType >::check(), FIR::Filter< SampleType >::fifo, FIR::Filter< SampleType >::pos, FIR::Filter< SampleType >::processSingleSample(), and FIR::Filter< SampleType >::size.

◆ processSingleSample()

template<typename SampleType >
static SampleType JUCE_VECTOR_CALLTYPE FIR::Filter< SampleType >::processSingleSample ( SampleType  sample,
SampleType *  buf,
const NumericType fir,
size_t  m,
size_t &  p 
)
inlinestaticprivatenoexcept

◆ reset()

template<typename SampleType >
void FIR::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. To disable the filter, call setEnabled (false).

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

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

Member Data Documentation

◆ coefficients

template<typename SampleType >
Coefficients<NumericType>::Ptr 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 FIR::Coefficients< NumericType >::Coefficients(), FIR::Coefficients< NumericType >::getFilterOrder(), FIR::Coefficients< NumericType >::getRawCoefficients(), FIR::Coefficients< NumericType >::operator=(), and FIR::Filter< SampleType >::reset().

◆ fifo

template<typename SampleType >
SampleType* FIR::Filter< SampleType >::fifo = nullptr
private

◆ memory

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

◆ pos

template<typename SampleType >
size_t FIR::Filter< SampleType >::pos = 0
private

◆ size


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