EMA function optimized

This commit is contained in:
tudnai 2021-11-05 07:13:11 -07:00
parent 22b91fc12d
commit b3b69fbd82

View File

@ -396,13 +396,8 @@ void spkr_toggle_edge_old ( const int level_max, const float initial_edge, const
int ema( int val, int prev ) {
static const float ema_sensitivity = 2;
static const float ema_len = 14;
float m = ema_sensitivity / ema_len;
float n = 1 - m;
if ( prev == 0 ) {
prev = 1;
}
static const float m = ema_sensitivity / ema_len;
static const float n = 1 - m;
// calculate the multiplier for smoothing (weighting) the EMA,
// which typically follows the formula: [2 ÷ (number of observations + 1)].