JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::dsp::FirstOrderTPTFilter< SampleType > Class Template Reference

A first order filter class using the TPT (Topology-Preserving Transform) structure. More...

#include <juce_FirstOrderTPTFilter.h>

Collaboration diagram for juce::dsp::FirstOrderTPTFilter< SampleType >:

Public Types

using Type = FirstOrderTPTFilterType
 

Public Member Functions

 FirstOrderTPTFilter ()
 Constructor. More...
 
SampleType getCutoffFrequency () const noexcept
 Returns the cutoff frequency of the filter. More...
 
Type getType () const noexcept
 Returns the type of the filter. More...
 
void prepare (const ProcessSpec &spec)
 Initialises the filter. More...
 
template<typename ProcessContext >
void process (const ProcessContext &context) noexcept
 Processes the input and output samples supplied in the processing context. More...
 
SampleType processSample (int channel, SampleType inputValue)
 Processes one sample at a time on a given channel. More...
 
void reset ()
 Resets the internal state variables of the filter. More...
 
void reset (SampleType newValue)
 Resets the internal state variables of the filter to a given value. More...
 
void setCutoffFrequency (SampleType newFrequencyHz)
 Sets the cutoff frequency of the filter. More...
 
void setType (Type newType)
 Sets the filter type. More...
 
void snapToZero () noexcept
 Ensure that the state variables are rounded to zero if the state variables are denormals. More...
 

Private Member Functions

void update ()
 

Private Attributes

SampleType cutoffFrequency = 1000.0
 
Type filterType = Type::lowpass
 
SampleType G = 0
 
std::vector< SampleType > s1 { 2 }
 
double sampleRate = 44100.0
 

Detailed Description

template<typename SampleType>
class juce::dsp::FirstOrderTPTFilter< SampleType >

A first order filter class using the TPT (Topology-Preserving Transform) structure.

This filter can be modulated at high rates without producing audio artefacts. See Vadim Zavalishin's documentation about TPT structures for more information.

Note: Using this class prevents some loud audio artefacts commonly encountered when changing the cutoff frequency using of other filter simulation structures and IIR filter classes. However, this class may still require additional smoothing for cutoff frequency changes.

see StateVariableFilter, IIRFilter, SmoothedValue

@tags{DSP}

Member Typedef Documentation

◆ Type

template<typename SampleType >
using juce::dsp::FirstOrderTPTFilter< SampleType >::Type = FirstOrderTPTFilterType

Constructor & Destructor Documentation

◆ FirstOrderTPTFilter()

template<typename SampleType >
juce::dsp::FirstOrderTPTFilter< SampleType >::FirstOrderTPTFilter ( )

Constructor.

Member Function Documentation

◆ getCutoffFrequency()

template<typename SampleType >
SampleType juce::dsp::FirstOrderTPTFilter< SampleType >::getCutoffFrequency ( ) const
inlinenoexcept

Returns the cutoff frequency of the filter.

References juce::dsp::FirstOrderTPTFilter< SampleType >::cutoffFrequency.

◆ getType()

template<typename SampleType >
Type juce::dsp::FirstOrderTPTFilter< SampleType >::getType ( ) const
inlinenoexcept

Returns the type of the filter.

References juce::dsp::FirstOrderTPTFilter< SampleType >::filterType.

◆ prepare()

template<typename SampleType >
void juce::dsp::FirstOrderTPTFilter< SampleType >::prepare ( const ProcessSpec spec)

Initialises the filter.

◆ process()

template<typename SampleType >
template<typename ProcessContext >
void juce::dsp::FirstOrderTPTFilter< SampleType >::process ( const ProcessContext context)
inlinenoexcept

◆ processSample()

template<typename SampleType >
SampleType juce::dsp::FirstOrderTPTFilter< SampleType >::processSample ( int  channel,
SampleType  inputValue 
)

Processes one sample at a time on a given channel.

Referenced by juce::dsp::FirstOrderTPTFilter< SampleType >::process().

◆ reset() [1/2]

template<typename SampleType >
void juce::dsp::FirstOrderTPTFilter< SampleType >::reset ( )

Resets the internal state variables of the filter.

◆ reset() [2/2]

template<typename SampleType >
void juce::dsp::FirstOrderTPTFilter< SampleType >::reset ( SampleType  newValue)

Resets the internal state variables of the filter to a given value.

◆ setCutoffFrequency()

template<typename SampleType >
void juce::dsp::FirstOrderTPTFilter< SampleType >::setCutoffFrequency ( SampleType  newFrequencyHz)

Sets the cutoff frequency of the filter.

Parameters
newFrequencyHzcutoff frequency in Hz.

◆ setType()

template<typename SampleType >
void juce::dsp::FirstOrderTPTFilter< SampleType >::setType ( Type  newType)

Sets the filter type.

◆ snapToZero()

template<typename SampleType >
void juce::dsp::FirstOrderTPTFilter< SampleType >::snapToZero ( )
noexcept

Ensure that the state variables are rounded to zero if the state variables are denormals.

This is only needed if you are doing sample by sample processing.

Referenced by juce::dsp::FirstOrderTPTFilter< SampleType >::process().

◆ update()

template<typename SampleType >
void juce::dsp::FirstOrderTPTFilter< SampleType >::update ( )
private

Member Data Documentation

◆ cutoffFrequency

template<typename SampleType >
SampleType juce::dsp::FirstOrderTPTFilter< SampleType >::cutoffFrequency = 1000.0
private

◆ filterType

template<typename SampleType >
Type juce::dsp::FirstOrderTPTFilter< SampleType >::filterType = Type::lowpass
private

◆ G

template<typename SampleType >
SampleType juce::dsp::FirstOrderTPTFilter< SampleType >::G = 0
private

◆ s1

template<typename SampleType >
std::vector<SampleType> juce::dsp::FirstOrderTPTFilter< SampleType >::s1 { 2 }
private

◆ sampleRate

template<typename SampleType >
double juce::dsp::FirstOrderTPTFilter< SampleType >::sampleRate = 44100.0
private

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