Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::dsp::OnePole Class Reference

A one-pole low-pass, exact for an input that holds through the frame. More...

Detailed Description

A one-pole low-pass, exact for an input that holds through the frame.

y += k (x - y) per frame, with k = 1 - e^(-2 pi fc) for a cutoff fc in cycles per frame: the low-pass whose response to an input that holds through the frame is exact, y(t) = x + (y(0) - x) e^(-2 pi fc t). The same form holds over any time, so coefficient_for(cutoff, frames) gives the coefficient for a part of a frame or for several, and process(x, coefficient) advances by that time toward a held input. An owner that knows when its input stepped within a frame can advance to the step and on from it, and so follow the input itself instead of samples of it.

Below the signal transport: the cutoff is in cycles per frame, set by the component or app that owns it; it holds no sample rate. It declares no ports; the buffer call takes none, and PARAMETERS names the cutoff so a tool can run it alone. A non-finite or negative cutoff or time gives a coefficient of 0, where the output holds. The input is not tested, as DcBlock's is not: a non-finite input stays in the state until reset(), and its owner keeps it out. Until a cutoff is set the coefficient is 1, and the output follows the input.

Definition at line 38 of file one_pole.hpp.

#include <one_pole.hpp>

Public Member Functions

void set_cutoff (float cycles_per_frame)
 Set the cutoff for the one-frame calls.
 
float process (float x)
 One frame.
 
float process (float x, float coefficient)
 An advance by the time coefficient was worked for, toward an input that holds through it.
 
void process (const float *in, float *out, uint16_t frames)
 A buffer of frames. In place is fine: out may be in.
 
void reset (float value=0.0f)
 The output jumps to a value.
 
float value () const
 The current output.
 
float coefficient () const
 The coefficient the one-frame calls use.
 

Static Public Member Functions

static float coefficient_for (float cutoff_cycles_per_frame, float frames=1.0f)
 The coefficient for a cutoff over a time: 1 - e^(-2 pi cutoff frames), in [0, 1).
 

Static Public Attributes

static constexpr transport::Parameter< OnePole > PARAMETERS []
 The parameters, for tools.
 

Member Function Documentation

◆ coefficient_for()

static float sbl::dsp::OnePole::coefficient_for ( float  cutoff_cycles_per_frame,
float  frames = 1.0f 
)
inlinestatic

The coefficient for a cutoff over a time: 1 - e^(-2 pi cutoff frames), in [0, 1).

Parameters
cutoff_cycles_per_frameThe corner, in cycles per frame
framesThe time one process() call covers, in frames; 1 by default
Returns
The coefficient; 0 when cutoff * frames is not finite or not above 0

Definition at line 47 of file one_pole.hpp.

References sbl::math::TWO_PI.

Referenced by set_cutoff().

◆ set_cutoff()

void sbl::dsp::OnePole::set_cutoff ( float  cycles_per_frame)
inline

Set the cutoff for the one-frame calls.

Parameters
cycles_per_frameCutoff in cycles per frame; a non-finite or non-positive value holds the output
Context
Same thread as process(); real-time safe.

Definition at line 61 of file one_pole.hpp.

References coefficient_for().

◆ process() [1/3]

float sbl::dsp::OnePole::process ( float  x)
inline

One frame.

Parameters
xInput sample
Returns
Output sample
Context
Audio thread; real-time safe.

Definition at line 70 of file one_pole.hpp.

References process().

Referenced by process(), and process().

◆ process() [2/3]

float sbl::dsp::OnePole::process ( float  x,
float  coefficient 
)
inline

An advance by the time coefficient was worked for, toward an input that holds through it.

Parameters
xInput, held through the advance
coefficientA coefficient from coefficient_for(), in [0, 1)
Returns
Output after the advance
Context
Audio thread; real-time safe.

Definition at line 80 of file one_pole.hpp.

References coefficient().

◆ process() [3/3]

void sbl::dsp::OnePole::process ( const float *  in,
float *  out,
uint16_t  frames 
)
inline

A buffer of frames. In place is fine: out may be in.

Parameters
inInput buffer, frames long
[out]outOutput buffer, frames long
framesFrame count
Context
Audio thread; real-time safe.

Definition at line 98 of file one_pole.hpp.

References process().

◆ reset()

void sbl::dsp::OnePole::reset ( float  value = 0.0f)
inline

The output jumps to a value.

Parameters
valueNew output; a non-finite value gives 0

Definition at line 109 of file one_pole.hpp.

References value().

◆ value()

float sbl::dsp::OnePole::value ( ) const
inline

The current output.

Definition at line 112 of file one_pole.hpp.

Referenced by reset().

◆ coefficient()

float sbl::dsp::OnePole::coefficient ( ) const
inline

The coefficient the one-frame calls use.

Definition at line 114 of file one_pole.hpp.

Referenced by process().

Member Data Documentation

◆ PARAMETERS

constexpr transport::Parameter<OnePole> sbl::dsp::OnePole::PARAMETERS[]
staticconstexpr
Initial value:
= {
}
void set_cutoff(float cycles_per_frame)
Set the cutoff for the one-frame calls.
Definition one_pole.hpp:61

The parameters, for tools.

Definition at line 86 of file one_pole.hpp.


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