From 9fd35ba3611e840fa39d8d14fcc163bbb36b283d Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Sat, 24 Jan 2026 09:43:46 +0300 Subject: [PATCH] Simplify lpf filter code Begin with zero instead of the initializing value, as the latter doesn't make much sense in practice, but complicates the code much. --- flix/lpf.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/flix/lpf.h b/flix/lpf.h index 88cf8ab..9eae80d 100644 --- a/flix/lpf.h +++ b/flix/lpf.h @@ -14,15 +14,6 @@ public: LowPassFilter(float alpha): alpha(alpha) {}; T update(const T input) { - if (alpha == 1) { // filter disabled - return input; - } - - if (!initialized) { - output = input; - initialized = true; - } - return output += alpha * (input - output); } @@ -31,9 +22,6 @@ public: } void reset() { - initialized = false; + output = T(); // set to zero } - -private: - bool initialized = false; };