Function tap::algorithms::lowPassFilter
Defined in File math_user_utils.hpp
Function Documentation
-
inline float tap::algorithms::lowPassFilter(float prevValue, float newValue, float alpha)
A simple floating point low pass filter, e.g. \(y_{filtered} = \alpha \cdot y_{n+1} + (1-\alpha) \cdot y_n\)
Here is a simple use case. To use the low pass filter, pass in the val you are low passing in as the first parameter and have that value accept what lowPassFilter returns.
val = lowPassFilter(val, newValue, 0.1f);
Note
Only use this if you are willing to introduce some lag into your system, and be careful if you do.
- Parameters:
prevValue – [in] The previous low passed value.
newValue – [in] The new data to be passed into the low pass filter.
alpha – [in] The amount of smoothing. The larger the alpha, the less smoothing occurs. An alpha of 1 means that you want to favor the newValue and thus is not doing any filtering. Must be between [0, 1].
- Returns:
The newly low passed filter data.