20#ifndef SBL_PRIMITIVES_MATH_EWMA_HPP_
21#define SBL_PRIMITIVES_MATH_EWMA_HPP_
35 explicit Ewma(uint8_t shift = 3) : shift_(shift), state_(0), primed_(false) {}
47 uint32_t input_q16 =
static_cast<uint32_t
>(raw) << 16;
55 int32_t delta =
static_cast<int32_t
>(input_q16 - state_);
56 state_ +=
static_cast<uint32_t
>(delta >> shift_);
59 return static_cast<uint16_t
>(state_ >> 16);
64 return static_cast<uint16_t
>(state_ >> 16);
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 reset()
Reset filter state (next update will re-seed)
Root namespace for all Sound Byte Libs functionality.