Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Classes | Namespaces
ewma.hpp File Reference

Exponentially Weighted Moving Average filter. More...

#include <cstdint>
Include dependency graph for ewma.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  sbl::primitives::math::Ewma
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs functionality.
 
namespace  sbl::primitives
 Essential data structures and algorithms.
 
namespace  sbl::primitives::math
 

Detailed Description

Exponentially Weighted Moving Average filter.

Integer-only EWMA with Q16 internal state for sub-LSB precision. Uses power-of-2 shift for the smoothing factor (no division). Suitable for Cortex-M0+ (no FPU required).

Alpha = 1 / 2^shift: shift=1 → alpha=1/2 (fast tracking, little smoothing) shift=3 → alpha=1/8 (good default for pots) shift=5 → alpha=1/32 (heavy smoothing)

Usage: sbl::primitives::math::Ewma filter(3); uint16_t smoothed = filter.update(raw_adc_value);

Definition in file ewma.hpp.