diff options
Diffstat (limited to 'examples/6_iir_test.cpp')
-rw-r--r-- | examples/6_iir_test.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/6_iir_test.cpp b/examples/6_iir_test.cpp new file mode 100644 index 0000000..116a680 --- /dev/null +++ b/examples/6_iir_test.cpp @@ -0,0 +1,13 @@ +Sample *process_data(Samples samples) +{ + constexpr float alpha = 0.7; + + static Sample prev = 2048; + + samples[0] = (1 - alpha) * samples[0] + alpha * prev; + for (unsigned int i = 1; i < samples.size(); i++) + samples[i] = (1 - alpha) * samples[i] + alpha * samples[i - 1]; + prev = samples[samples.size() - 1]; + + return samples.data(); +} |