Skip to content

Commit

Permalink
#173: casual lowpass filter
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitryP6 committed Nov 17, 2024
1 parent a7015f1 commit 2f4449d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions simple_ema.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>

// Exponential Moving Average Lowpass Filter
void ema_filter(float current_value, float *previous_ema, float alpha) {
*previous_ema = (alpha * current_value) + ((1 - alpha) * (*previous_ema));
}

int main() {
float alpha = 0.1f; // smoothing strength
float ema = 0.0f; // initial value can be 0
// Something like : ema_filter(curent_unfiltered_value, &ema, alpha)
return 0;
}

0 comments on commit 2f4449d

Please sign in to comment.