28template <
typename T =
float>
37 const int n =
static_cast<int>(bins.
size());
38 if (n == 0)
return T(0);
41 if (
mSmoothed.size() !=
static_cast<fl::size
>(n)) {
43 for (
int i = 0; i < n; ++i) {
50 T sumRelChange = T(0);
53 for (
int i = 0; i < n; ++i) {
59 T diff = bins[i] - smoothed;
60 T absDiff = (diff >= T(0)) ? diff : -diff;
61 sumRelChange += absDiff / denom;
70 ? sumRelChange /
static_cast<T
>(activeCount)
void setAlpha(T alpha)
Change the EMA alpha (tracking speed).
fl::vector< T > mSmoothed
T update(fl::span< const T > bins)
Feed a new frame of multi-channel data.
void reset()
Reset all internal state.
T value() const
Get the last computed variance without updating.
SpectralVarianceImpl(T alpha=T(0.2f), T floor=T(1e-4f))
fl::size size() const
Get the number of channels being tracked.
void setFloor(T floor)
Change the floor threshold for active channel detection.
constexpr fl::size size() const FL_NOEXCEPT
Compile-time linker keep-alive hook for a single fl::Bus.
constexpr enable_if< is_fixed_point< T >::value, T >::type floor(T x) FL_NOEXCEPT
Base definition for an LED controller.