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::StateVariableTPTFilter< SampleType > Class Template Reference

An IIR filter that can perform low, band and high-pass filtering on an audio signal, with 12 dB of attenuation per octave, using a TPT structure, designed for fast modulation (see Vadim Zavalishin's documentation about TPT structures for more information). More...

#include <juce_StateVariableTPTFilter.h>

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

Public Types

using Type = StateVariableTPTFilterType
 

Public Member Functions

 StateVariableTPTFilter ()
 Constructor. More...
 
SampleType getCutoffFrequency () const noexcept
 Returns the cutoff frequency of the filter. More...
 
SampleType getResonance () const noexcept
 Returns the resonance 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 setResonance (SampleType newResonance)
 Sets the resonance 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 = static_cast<SampleType> (1000.0)
 
Type filterType = Type::lowpass
 
SampleType g
 
SampleType h
 
SampleType R2
 
SampleType resonance = static_cast<SampleType> (1.0 / std::sqrt (2.0))
 
std::vector< SampleType > s1 { 2 }
 
std::vector< SampleType > s2 { 2 }
 
double sampleRate = 44100.0
 

Detailed Description

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

An IIR filter that can perform low, band and high-pass filtering on an audio signal, with 12 dB of attenuation per octave, using a TPT structure, designed for fast modulation (see Vadim Zavalishin's documentation about TPT structures for more information).

Its behaviour is based on the analog state variable filter circuit.

Note: The bandpass here is not the one in the RBJ CookBook as its gain can be higher than 0 dB. For the classic 0 dB bandpass, we need to multiply the result by R2.

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

see IIRFilter, SmoothedValue

@tags{DSP}

Member Typedef Documentation

◆ Type

template<typename SampleType >
using juce::dsp::StateVariableTPTFilter< SampleType >::Type = StateVariableTPTFilterType

Constructor & Destructor Documentation

◆ StateVariableTPTFilter()

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

Constructor.

Member Function Documentation

◆ getCutoffFrequency()

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

Returns the cutoff frequency of the filter.

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

◆ getResonance()

template<typename SampleType >
SampleType juce::dsp::StateVariableTPTFilter< SampleType >::getResonance ( ) const
inlinenoexcept

Returns the resonance of the filter.

References juce::dsp::StateVariableTPTFilter< SampleType >::resonance.

◆ getType()

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

Returns the type of the filter.

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

◆ prepare()

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

Initialises the filter.

◆ process()

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

◆ processSample()

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

Processes one sample at a time on a given channel.

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

◆ reset() [1/2]

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

Resets the internal state variables of the filter.

◆ reset() [2/2]

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

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

◆ setCutoffFrequency()

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

Sets the cutoff frequency of the filter.

Parameters
newFrequencyHzthe new cutoff frequency in Hz.

◆ setResonance()

template<typename SampleType >
void juce::dsp::StateVariableTPTFilter< SampleType >::setResonance ( SampleType  newResonance)

Sets the resonance of the filter.

Note: The bandwidth of the resonance increases with the value of the parameter. To have a standard 12 dB / octave filter, the value must be set at 1 / sqrt(2).

◆ setType()

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

Sets the filter type.

◆ snapToZero()

template<typename SampleType >
void juce::dsp::StateVariableTPTFilter< 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::StateVariableTPTFilter< SampleType >::process().

◆ update()

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

Member Data Documentation

◆ cutoffFrequency

template<typename SampleType >
SampleType juce::dsp::StateVariableTPTFilter< SampleType >::cutoffFrequency = static_cast<SampleType> (1000.0)
private

◆ filterType

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

◆ g

template<typename SampleType >
SampleType juce::dsp::StateVariableTPTFilter< SampleType >::g
private

◆ h

template<typename SampleType >
SampleType juce::dsp::StateVariableTPTFilter< SampleType >::h
private

◆ R2

template<typename SampleType >
SampleType juce::dsp::StateVariableTPTFilter< SampleType >::R2
private

◆ resonance

template<typename SampleType >
SampleType juce::dsp::StateVariableTPTFilter< SampleType >::resonance = static_cast<SampleType> (1.0 / std::sqrt (2.0))
private

◆ s1

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

◆ s2

template<typename SampleType >
std::vector<SampleType> juce::dsp::StateVariableTPTFilter< SampleType >::s2 { 2 }
private

◆ sampleRate

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

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