I'm applying an Exponential Moving Average
as filter for smooth params within my audio application:
a0 = 0.01
z += a0 * (input - z);
Here's the code and the firsts 50 steps:
#include <iostream>
int main ()
{
double a0 = 0.1;
double input = 0.8;
double z = 0.0;
std::cout << "init z: " << z << std::endl << std::endl;
for(int i=0; i < 50; i++) {
z += a0 * (input - z);
std::cout << z << std::endl;
}
std::cout << std::endl << "final z: " << z << std::endl;
}
I need to check if the prev smoothed value is the same of the current one, which mean that the filter has "finished" its smothing process, and the value will always be the same.
But z
will always differs an epsilon
from input
, so I can't check input == z
it wil always be false. Here's an example, with infinite loop.
What will be the epsilon between z
and input
? So if its within that range, I can check and avoid further operations.