Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::primitives::math::Ewma Class Reference

Detailed Description

Definition at line 29 of file ewma.hpp.

#include <ewma.hpp>

Public Member Functions

 Ewma (uint8_t shift=3)
 Construct EWMA filter.
 
uint16_t update (uint16_t raw)
 Feed a new sample and return the smoothed value.
 
uint16_t value () const
 Return current smoothed value without updating.
 
void set_shift (uint8_t shift)
 Change smoothing exponent without resetting filter state.
 
void reset ()
 Reset filter state (next update will re-seed)
 

Constructor & Destructor Documentation

◆ Ewma()

sbl::primitives::math::Ewma::Ewma ( uint8_t  shift = 3)
inlineexplicit

Construct EWMA filter.

Parameters
shiftSmoothing exponent (alpha = 1/2^shift). Range: 1–15.

Definition at line 35 of file ewma.hpp.

Member Function Documentation

◆ update()

uint16_t sbl::primitives::math::Ewma::update ( uint16_t  raw)
inline

Feed a new sample and return the smoothed value.

First call seeds the filter (no smoothing on first sample). Internal state uses Q16 fixed-point for sub-LSB precision.

Parameters
rawRaw input value (16-bit)
Returns
Smoothed output (16-bit)

Definition at line 46 of file ewma.hpp.

Referenced by sbl::components::cv::CvInput::update(), and sbl::components::input::Pot::update().

◆ value()

uint16_t sbl::primitives::math::Ewma::value ( ) const
inline

Return current smoothed value without updating.

Definition at line 63 of file ewma.hpp.

Referenced by sbl::components::input::Pot::smoothed(), and sbl::components::cv::CvInput::value().

◆ set_shift()

void sbl::primitives::math::Ewma::set_shift ( uint8_t  shift)
inline

Change smoothing exponent without resetting filter state.

Definition at line 68 of file ewma.hpp.

Referenced by sbl::components::cv::CvInput::set_smoothing().

◆ reset()

void sbl::primitives::math::Ewma::reset ( )
inline

Reset filter state (next update will re-seed)

Definition at line 71 of file ewma.hpp.

Referenced by sbl::components::cv::CvInput::reset(), and sbl::components::input::Pot::reset().


The documentation for this class was generated from the following file: