JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::dsp::FilterDesign< FloatType > Struct Template Reference

This class provides a set of functions which generates FIR::Coefficients and IIR::Coefficients, of high-order low-pass filters. More...

#include <juce_FilterDesign.h>

Classes

struct  IIRPolyphaseAllpassStructure
 The structure returned by the function designIIRLowpassHalfBandPolyphaseAllpassMethod. More...
 

Public Types

using FIRCoefficientsPtr = typename FIR::Coefficients< FloatType >::Ptr
 
using IIRCoefficients = typename IIR::Coefficients< FloatType >
 
using WindowingMethod = typename WindowingFunction< FloatType >::WindowingMethod
 

Static Public Member Functions

static FIRCoefficientsPtr designFIRLowpassHalfBandEquirippleMethod (FloatType normalizedTransitionWidth, FloatType attenuationdB)
 This method generates a FIR::Coefficients for a low-pass filter, with a cutoff frequency at half band, using an algorithm described in the article "Design of Half-Band FIR Filters for Signal Compression" from Pavel Zahradnik, to get an equiripple like high order FIR filter, without the need of an iterative method and convergence failure risks. More...
 
static FIRCoefficientsPtr designFIRLowpassKaiserMethod (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType attenuationdB)
 This a variant of the function designFIRLowpassWindowMethod, which allows the user to specify a transition width and an attenuation in dB, to get a low-pass filter using the Kaiser windowing function, with calculated values of the filter order and of the beta parameter, to satisfy the constraints. More...
 
static FIRCoefficientsPtr designFIRLowpassLeastSquaresMethod (FloatType frequency, double sampleRate, size_t order, FloatType normalizedTransitionWidth, FloatType stopBandWeight)
 This method generates a FIR::Coefficients for a low-pass filter, by minimizing the average error between the generated filter and an ideal one using the least squares error criterion and matrices operations. More...
 
static FIRCoefficientsPtr designFIRLowpassTransitionMethod (FloatType frequency, double sampleRate, size_t order, FloatType normalizedTransitionWidth, FloatType spline)
 This method is also a variant of the function designFIRLowpassWindowMethod, using a rectangular window as a basis, and a spline transition between the pass band and the stop band, to reduce the Gibbs phenomenon. More...
 
static FIRCoefficientsPtr designFIRLowpassWindowMethod (FloatType frequency, double sampleRate, size_t order, WindowingMethod type, FloatType beta=static_cast< FloatType >(2))
 This method generates a FIR::Coefficients for a low-pass filter, using the windowing design method, applied to a sinc impulse response. More...
 
static ReferenceCountedArray< IIRCoefficientsdesignIIRHighpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, int order)
 This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase high-pass filter without any ripple in the pass band and in the stop band. More...
 
static IIRPolyphaseAllpassStructure designIIRLowpassHalfBandPolyphaseAllpassMethod (FloatType normalizedTransitionWidth, FloatType stopbandAttenuationdB)
 This method generates arrays of IIR::Coefficients for a low-pass filter, with a cutoff frequency at half band, using an algorithm described in the article "Digital Signal Processing Schemes for efficient interpolation and decimation" from Pavel Valenzuela and Constantinides. More...
 
static ReferenceCountedArray< IIRCoefficientsdesignIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, FloatType stopbandAttenuationdB)
 This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any ripple in the pass band and in the stop band. More...
 
static ReferenceCountedArray< IIRCoefficientsdesignIIRLowpassHighOrderButterworthMethod (FloatType frequency, double sampleRate, int order)
 This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any ripple in the pass band and in the stop band. More...
 
static ReferenceCountedArray< IIRCoefficientsdesignIIRLowpassHighOrderChebyshev1Method (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, FloatType stopbandAttenuationdB)
 This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any ripple in the stop band only. More...
 
static ReferenceCountedArray< IIRCoefficientsdesignIIRLowpassHighOrderChebyshev2Method (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, FloatType stopbandAttenuationdB)
 This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any ripple in the pass band only. More...
 
static ReferenceCountedArray< IIRCoefficientsdesignIIRLowpassHighOrderEllipticMethod (FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, FloatType stopbandAttenuationdB)
 This method returns an array of IIR::Coefficients, made to be used in cascaded IIR::Filters, providing a minimum phase low-pass filter with ripples in both the pass band and in the stop band. More...
 

Private Member Functions

 FilterDesign ()=delete
 

Static Private Member Functions

static ReferenceCountedArray< IIRCoefficientsdesignIIRLowpassHighOrderGeneralMethod (int type, FloatType frequency, double sampleRate, FloatType normalizedTransitionWidth, FloatType passbandAttenuationdB, FloatType stopbandAttenuationdB)
 
static Array< double > getPartialImpulseResponseHn (int n, double kp)
 

Detailed Description

template<typename FloatType>
struct juce::dsp::FilterDesign< FloatType >

This class provides a set of functions which generates FIR::Coefficients and IIR::Coefficients, of high-order low-pass filters.

They can be used for processing directly audio as an equalizer, in resampling algorithms etc.

see FIRFilter::Coefficients, FIRFilter, WindowingFunction, IIRFilter::Coefficients, IIRFilter

{DSP}

Member Typedef Documentation

◆ FIRCoefficientsPtr

template<typename FloatType >
using juce::dsp::FilterDesign< FloatType >::FIRCoefficientsPtr = typename FIR::Coefficients<FloatType>::Ptr

◆ IIRCoefficients

template<typename FloatType >
using juce::dsp::FilterDesign< FloatType >::IIRCoefficients = typename IIR::Coefficients<FloatType>

◆ WindowingMethod

template<typename FloatType >
using juce::dsp::FilterDesign< FloatType >::WindowingMethod = typename WindowingFunction<FloatType>::WindowingMethod

Constructor & Destructor Documentation

◆ FilterDesign()

template<typename FloatType >
juce::dsp::FilterDesign< FloatType >::FilterDesign ( )
privatedelete

Member Function Documentation

◆ designFIRLowpassHalfBandEquirippleMethod()

template<typename FloatType >
static FIRCoefficientsPtr juce::dsp::FilterDesign< FloatType >::designFIRLowpassHalfBandEquirippleMethod ( FloatType  normalizedTransitionWidth,
FloatType  attenuationdB 
)
static

This method generates a FIR::Coefficients for a low-pass filter, with a cutoff frequency at half band, using an algorithm described in the article "Design of Half-Band FIR Filters for Signal Compression" from Pavel Zahradnik, to get an equiripple like high order FIR filter, without the need of an iterative method and convergence failure risks.

It generates linear phase filters coefficients.

Parameters
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
attenuationdBthe attenuation in dB expected in the stop band

◆ designFIRLowpassKaiserMethod()

template<typename FloatType >
static FIRCoefficientsPtr juce::dsp::FilterDesign< FloatType >::designFIRLowpassKaiserMethod ( FloatType  frequency,
double  sampleRate,
FloatType  normalizedTransitionWidth,
FloatType  attenuationdB 
)
static

This a variant of the function designFIRLowpassWindowMethod, which allows the user to specify a transition width and an attenuation in dB, to get a low-pass filter using the Kaiser windowing function, with calculated values of the filter order and of the beta parameter, to satisfy the constraints.

It generates linear phase filters coefficients.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
attenuationdBthe attenuation in dB expected in the stop band

◆ designFIRLowpassLeastSquaresMethod()

template<typename FloatType >
static FIRCoefficientsPtr juce::dsp::FilterDesign< FloatType >::designFIRLowpassLeastSquaresMethod ( FloatType  frequency,
double  sampleRate,
size_t  order,
FloatType  normalizedTransitionWidth,
FloatType  stopBandWeight 
)
static

This method generates a FIR::Coefficients for a low-pass filter, by minimizing the average error between the generated filter and an ideal one using the least squares error criterion and matrices operations.

It generates linear phase filters coefficients.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
orderthe order of the filter
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
stopBandWeightbetween 1.0 and 100.0, indicates how much we want attenuation in the stop band, against some oscillation in the pass band

◆ designFIRLowpassTransitionMethod()

template<typename FloatType >
static FIRCoefficientsPtr juce::dsp::FilterDesign< FloatType >::designFIRLowpassTransitionMethod ( FloatType  frequency,
double  sampleRate,
size_t  order,
FloatType  normalizedTransitionWidth,
FloatType  spline 
)
static

This method is also a variant of the function designFIRLowpassWindowMethod, using a rectangular window as a basis, and a spline transition between the pass band and the stop band, to reduce the Gibbs phenomenon.

It generates linear phase filters coefficients.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
orderthe order of the filter
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
splinebetween 1.0 and 4.0, indicates how much the transition is curved, with 1.0 meaning a straight line

◆ designFIRLowpassWindowMethod()

template<typename FloatType >
static FIRCoefficientsPtr juce::dsp::FilterDesign< FloatType >::designFIRLowpassWindowMethod ( FloatType  frequency,
double  sampleRate,
size_t  order,
WindowingMethod  type,
FloatType  beta = static_cast< FloatType >(2) 
)
static

This method generates a FIR::Coefficients for a low-pass filter, using the windowing design method, applied to a sinc impulse response.

It is one of the simplest method used to generate a high order low-pass filter, which has the downside of needing more coefficients than more complex method to perform a given attenuation in the stop band.

It generates linear phase filters coefficients.

Note: The flatTop WindowingMethod generates an impulse response with a maximum amplitude higher than one, and might be normalized if necessary depending on the applications.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
orderthe order of the filter
typethe type, must be a WindowingFunction::WindowingType
betaan optional additional parameter useful for the Kaiser windowing function

◆ designIIRHighpassHighOrderButterworthMethod()

template<typename FloatType >
static ReferenceCountedArray<IIRCoefficients> juce::dsp::FilterDesign< FloatType >::designIIRHighpassHighOrderButterworthMethod ( FloatType  frequency,
double  sampleRate,
int  order 
)
static

This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase high-pass filter without any ripple in the pass band and in the stop band.

Parameters
frequencythe cutoff frequency of the high-pass filter
sampleRatethe sample rate being used in the filter design
orderthe order of the resulting IIR filter, providing an attenuation of -6 dB times order / octave

◆ designIIRLowpassHalfBandPolyphaseAllpassMethod()

template<typename FloatType >
static IIRPolyphaseAllpassStructure juce::dsp::FilterDesign< FloatType >::designIIRLowpassHalfBandPolyphaseAllpassMethod ( FloatType  normalizedTransitionWidth,
FloatType  stopbandAttenuationdB 
)
static

This method generates arrays of IIR::Coefficients for a low-pass filter, with a cutoff frequency at half band, using an algorithm described in the article "Digital Signal Processing Schemes for efficient interpolation and decimation" from Pavel Valenzuela and Constantinides.

The result is a IIRPolyphaseAllpassStructure object.

The two members of this structure directPath and delayedPath are arrays of IIR::Coefficients, made of polyphase second order allpass filters and an additional delay in the second array, that can be used in cascaded filters processed in two parallel paths, which must be summed at the end to get the high order efficient low-pass filtering.

The gain of the resulting pass-band is 6 dB, so don't forget to compensate it if you want to use that method for something else than two times oversampling.

Parameters
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
stopbandAttenuationdBthe attenuation in dB expected in the stop band

◆ designIIRLowpassHighOrderButterworthMethod() [1/2]

template<typename FloatType >
static ReferenceCountedArray<IIRCoefficients> juce::dsp::FilterDesign< FloatType >::designIIRLowpassHighOrderButterworthMethod ( FloatType  frequency,
double  sampleRate,
FloatType  normalizedTransitionWidth,
FloatType  passbandAttenuationdB,
FloatType  stopbandAttenuationdB 
)
static

This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any ripple in the pass band and in the stop band.

The algorithms are based on "Lecture Notes on Elliptic Filter Design" by Sophocles J. Orfanidis.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
passbandAttenuationdBthe lowest attenuation in dB expected in the pass band
stopbandAttenuationdBthe attenuation in dB expected in the stop band

◆ designIIRLowpassHighOrderButterworthMethod() [2/2]

template<typename FloatType >
static ReferenceCountedArray<IIRCoefficients> juce::dsp::FilterDesign< FloatType >::designIIRLowpassHighOrderButterworthMethod ( FloatType  frequency,
double  sampleRate,
int  order 
)
static

This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any ripple in the pass band and in the stop band.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
orderthe order of the resulting IIR filter, providing an attenuation of -6 dB times order / octave

◆ designIIRLowpassHighOrderChebyshev1Method()

template<typename FloatType >
static ReferenceCountedArray<IIRCoefficients> juce::dsp::FilterDesign< FloatType >::designIIRLowpassHighOrderChebyshev1Method ( FloatType  frequency,
double  sampleRate,
FloatType  normalizedTransitionWidth,
FloatType  passbandAttenuationdB,
FloatType  stopbandAttenuationdB 
)
static

This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any ripple in the stop band only.

The algorithms are based on "Lecture Notes on Elliptic Filter Design" by Sophocles J. Orfanidis.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
passbandAttenuationdBthe lowest attenuation in dB expected in the pass band
stopbandAttenuationdBthe attenuation in dB expected in the stop band

◆ designIIRLowpassHighOrderChebyshev2Method()

template<typename FloatType >
static ReferenceCountedArray<IIRCoefficients> juce::dsp::FilterDesign< FloatType >::designIIRLowpassHighOrderChebyshev2Method ( FloatType  frequency,
double  sampleRate,
FloatType  normalizedTransitionWidth,
FloatType  passbandAttenuationdB,
FloatType  stopbandAttenuationdB 
)
static

This method returns an array of IIR::Coefficients, made to be used in cascaded IIRFilters, providing a minimum phase low-pass filter without any ripple in the pass band only.

The algorithms are based on "Lecture Notes on Elliptic Filter Design" by Sophocles J. Orfanidis.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
passbandAttenuationdBthe lowest attenuation in dB expected in the pass band
stopbandAttenuationdBthe attenuation in dB expected in the stop band

◆ designIIRLowpassHighOrderEllipticMethod()

template<typename FloatType >
static ReferenceCountedArray<IIRCoefficients> juce::dsp::FilterDesign< FloatType >::designIIRLowpassHighOrderEllipticMethod ( FloatType  frequency,
double  sampleRate,
FloatType  normalizedTransitionWidth,
FloatType  passbandAttenuationdB,
FloatType  stopbandAttenuationdB 
)
static

This method returns an array of IIR::Coefficients, made to be used in cascaded IIR::Filters, providing a minimum phase low-pass filter with ripples in both the pass band and in the stop band.

The algorithms are based on "Lecture Notes on Elliptic Filter Design" by Sophocles J. Orfanidis.

Parameters
frequencythe cutoff frequency of the low-pass filter
sampleRatethe sample rate being used in the filter design
normalizedTransitionWidththe normalized size between 0 and 0.5 of the transition between the pass band and the stop band
passbandAttenuationdBthe lowest attenuation in dB expected in the pass band
stopbandAttenuationdBthe attenuation in dB expected in the stop band

◆ designIIRLowpassHighOrderGeneralMethod()

template<typename FloatType >
static ReferenceCountedArray<IIRCoefficients> juce::dsp::FilterDesign< FloatType >::designIIRLowpassHighOrderGeneralMethod ( int  type,
FloatType  frequency,
double  sampleRate,
FloatType  normalizedTransitionWidth,
FloatType  passbandAttenuationdB,
FloatType  stopbandAttenuationdB 
)
staticprivate

◆ getPartialImpulseResponseHn()

template<typename FloatType >
static Array<double> juce::dsp::FilterDesign< FloatType >::getPartialImpulseResponseHn ( int  n,
double  kp 
)
staticprivate

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