A direct form i first order single pole lowpass filter. More...
#include <marvin_LPF.h>
Public Member Functions | |
void | initialise (double sampleRate) noexcept |
void | setCutoff (SampleType cutoff) noexcept |
void | setCoeff (SampleType newCoeff) noexcept |
SampleType | operator() (SampleType x) noexcept |
void | reset () noexcept |
A direct form i first order single pole lowpass filter.
|
noexcept |
Initialise the LPF's sample rate. If using setCutoff
to set the coefficient, make sure to call this function before any calls to it!
sampleRate | The sample rate the filter should run at. |
|
nodiscardnoexcept |
Filters a single sample. The lowpass is in the form y[n] = ax[n] + (1-a)y[n-1]
where a is the coeff
.
x | The sample to filter. |
|
noexcept |
Resets the internal state of the filter (including zero-ing y[n-1]
)
|
noexcept |
Directly sets the coefficient the filter should use internally - see setCutoff
for its relationship to cutoff.
As the internal coeff
variable is not atomic, ensure this function is either called on the audio thread, or that the audio thread is not running when this function is called.
newCoeff | The coeff the LPF should use. |
|
noexcept |
Sets the desired -3dB cutoff frequency for the filter. Make sure to call initialise
before calling this function. Internally, ends up calling setCoeff
with the calculated coeff, from the formula
which is explained in more detail here: https://dsp.stackexchange.com/questions/54086/single-pole-iir-low-pass-filter-which-is-the-correct-formula-for-the-decay-coe
As the internal coeff
variable is not atomic, this function needs to be either called on the audio thread, or called when the audio thread is not running.
cutoff | The cutoff frequency the LPF should use. |