Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::TptFilterT< SampleType > Class Template Reference

First-order TPT (trapezoidal integration) filter. More...

#include <tpt_filter.hpp>

Classes

struct  Outputs
 Process and return all three outputs at once. More...

Public Member Functions

 TptFilterT ()=default
void prepare (SampleType sample_rate)
void set_cutoff (SampleType hz)
 Set cutoff frequency in Hz. Safe to modulate per-sample.
SampleType cutoff () const
SampleType sample_rate () const
SampleType process_lowpass (SampleType input)
 Process and return the lowpass output.
SampleType process_highpass (SampleType input)
 Process and return the highpass output.
SampleType process_allpass (SampleType input)
 Process and return the allpass output.
void process_lowpass (SampleType *buffer, std::size_t num_samples)
 Process a buffer in place, replacing it with the lowpass output.
void process_highpass (SampleType *buffer, std::size_t num_samples)
 Process a buffer in place, replacing it with the highpass output.
void process_allpass (SampleType *buffer, std::size_t num_samples)
 Process a buffer in place, replacing it with the allpass output.
Outputs process (SampleType input)
void reset ()

Static Public Attributes

static constexpr SampleType kMinCutoffHz = SampleType{1}
static constexpr SampleType kMaxCutoffFraction = SampleType{0.49}
static constexpr SampleType kMinSampleRate = SampleType{4}
 Conservative defensive floor that leaves a non-empty valid cutoff interval above the 1 Hz lower bound.

Detailed Description

template<typename SampleType = float>
class pulp::signal::TptFilterT< SampleType >

First-order TPT (trapezoidal integration) filter.

Provides lowpass, highpass, and allpass outputs simultaneously. The TPT structure is unconditionally stable under modulation, making it ideal for filter FM and fast cutoff sweeps.

RT contract: prepare(), cutoff modulation, process paths, queries, and reset are fixed-state only and allocate no memory.

TptFilter filt;
filt.prepare(44100.0f);
filt.set_cutoff(1000.0f);
float lp = filt.process_lowpass(input);
SampleType process_lowpass(SampleType input)
Process and return the lowpass output.
Definition tpt_filter.hpp:68
void prepare(SampleType sample_rate)
Definition tpt_filter.hpp:41
void set_cutoff(SampleType hz)
Set cutoff frequency in Hz. Safe to modulate per-sample.
Definition tpt_filter.hpp:49
TptFilterT< float > TptFilter
Definition tpt_filter.hpp:172

Constructor & Destructor Documentation

◆ TptFilterT()

template<typename SampleType = float>
pulp::signal::TptFilterT< SampleType >::TptFilterT ( )
default

Member Function Documentation

◆ cutoff()

template<typename SampleType = float>
SampleType pulp::signal::TptFilterT< SampleType >::cutoff ( ) const
inline

◆ prepare()

template<typename SampleType = float>
void pulp::signal::TptFilterT< SampleType >::prepare ( SampleType sample_rate)
inline

◆ process()

template<typename SampleType = float>
Outputs pulp::signal::TptFilterT< SampleType >::process ( SampleType input)
inline

◆ process_allpass() [1/2]

template<typename SampleType = float>
void pulp::signal::TptFilterT< SampleType >::process_allpass ( SampleType * buffer,
std::size_t num_samples )
inline

Process a buffer in place, replacing it with the allpass output.

◆ process_allpass() [2/2]

template<typename SampleType = float>
SampleType pulp::signal::TptFilterT< SampleType >::process_allpass ( SampleType input)
inline

Process and return the allpass output.

◆ process_highpass() [1/2]

template<typename SampleType = float>
void pulp::signal::TptFilterT< SampleType >::process_highpass ( SampleType * buffer,
std::size_t num_samples )
inline

Process a buffer in place, replacing it with the highpass output.

◆ process_highpass() [2/2]

template<typename SampleType = float>
SampleType pulp::signal::TptFilterT< SampleType >::process_highpass ( SampleType input)
inline

Process and return the highpass output.

◆ process_lowpass() [1/2]

template<typename SampleType = float>
void pulp::signal::TptFilterT< SampleType >::process_lowpass ( SampleType * buffer,
std::size_t num_samples )
inline

Process a buffer in place, replacing it with the lowpass output.

Same arithmetic as the per-sample path on a register-resident state. The denormal snap runs once per kSnapChunkSamples chunk (snap_chunks()). The integrator's pole is 1 - 2g; unless |1 - 2g| < 0.44 (cutoffs near a quarter of the sample rate) a state at or above 1e-15 at the start of a chunk cannot decay into the float subnormal range before the next snap, and inside that band the tail falls through the subnormal range; there, and with subnormal input, the state can stay subnormal until the next snap, so residency is bounded by one chunk.

◆ process_lowpass() [2/2]

template<typename SampleType = float>
SampleType pulp::signal::TptFilterT< SampleType >::process_lowpass ( SampleType input)
inline

Process and return the lowpass output.

The state update is written as s + 2g * (input - s) (algebraically lp + v) so the recursion is one subtract and one multiply-add; the lowpass output is formed off that path.

◆ reset()

template<typename SampleType = float>
void pulp::signal::TptFilterT< SampleType >::reset ( )
inline

◆ sample_rate()

template<typename SampleType = float>
SampleType pulp::signal::TptFilterT< SampleType >::sample_rate ( ) const
inline

◆ set_cutoff()

template<typename SampleType = float>
void pulp::signal::TptFilterT< SampleType >::set_cutoff ( SampleType hz)
inline

Set cutoff frequency in Hz. Safe to modulate per-sample.

Member Data Documentation

◆ kMaxCutoffFraction

template<typename SampleType = float>
SampleType pulp::signal::TptFilterT< SampleType >::kMaxCutoffFraction = SampleType{0.49}
staticconstexpr

◆ kMinCutoffHz

template<typename SampleType = float>
SampleType pulp::signal::TptFilterT< SampleType >::kMinCutoffHz = SampleType{1}
staticconstexpr

◆ kMinSampleRate

template<typename SampleType = float>
SampleType pulp::signal::TptFilterT< SampleType >::kMinSampleRate = SampleType{4}
staticconstexpr

Conservative defensive floor that leaves a non-empty valid cutoff interval above the 1 Hz lower bound.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/signal/include/pulp/signal/tpt_filter.hpp