Filter: added reset with value to LowPassFilter2p

This commit is contained in:
Andrew Tridgell 2021-01-09 21:04:58 +11:00 committed by Peter Barker
parent 327db46c15
commit 4495414d05
2 changed files with 12 additions and 0 deletions

View File

@ -31,6 +31,11 @@ void DigitalBiquadFilter<T>::reset() {
_delay_element_1 = _delay_element_2 = T();
}
template <class T>
void DigitalBiquadFilter<T>::reset(const T &value) {
_delay_element_1 = _delay_element_2 = value;
}
template <class T>
void DigitalBiquadFilter<T>::compute_params(float sample_freq, float cutoff_freq, biquad_params &ret) {
ret.cutoff_freq = cutoff_freq;
@ -99,6 +104,11 @@ void LowPassFilter2p<T>::reset(void) {
return _filter.reset();
}
template <class T>
void LowPassFilter2p<T>::reset(const T &value) {
return _filter.reset(value);
}
/*
* Make an instances
* Otherwise we have to move the constructor implementations to the header file :P

View File

@ -39,6 +39,7 @@ public:
T apply(const T &sample, const struct biquad_params &params);
void reset();
void reset(const T &value);
static void compute_params(float sample_freq, float cutoff_freq, biquad_params &ret);
private:
@ -59,6 +60,7 @@ public:
float get_sample_freq(void) const;
T apply(const T &sample);
void reset(void);
void reset(const T &value);
protected:
struct DigitalBiquadFilter<T>::biquad_params _params;