LPF: add sample frequency getter

This commit is contained in:
Julien Lecoeur
2019-10-17 12:20:56 +02:00
parent a69e6b92c9
commit 7cb029288a
2 changed files with 5 additions and 0 deletions
@@ -43,6 +43,7 @@ namespace math
void LowPassFilter2pVector3f::set_cutoff_frequency(float sample_freq, float cutoff_freq) void LowPassFilter2pVector3f::set_cutoff_frequency(float sample_freq, float cutoff_freq)
{ {
_cutoff_freq = cutoff_freq; _cutoff_freq = cutoff_freq;
_sample_freq = sample_freq;
// reset delay elements on filter change // reset delay elements on filter change
_delay_element_1.zero(); _delay_element_1.zero();
@@ -74,12 +74,16 @@ public:
// Return the cutoff frequency // Return the cutoff frequency
float get_cutoff_freq() const { return _cutoff_freq; } float get_cutoff_freq() const { return _cutoff_freq; }
// Return the sample frequency
float get_sample_freq() const { return _sample_freq; }
// Reset the filter state to this value // Reset the filter state to this value
matrix::Vector3f reset(const matrix::Vector3f &sample); matrix::Vector3f reset(const matrix::Vector3f &sample);
private: private:
float _cutoff_freq{0.0f}; float _cutoff_freq{0.0f};
float _sample_freq{0.0f};
float _a1{0.0f}; float _a1{0.0f};
float _a2{0.0f}; float _a2{0.0f};