mirror of
https://github.com/okalachev/flix.git
synced 2026-02-16 23:21:31 +00:00
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.
This commit is contained in:
14
flix/lpf.h
14
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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user