|
FastLED 3.9.15
|
Multi-channel EMA with per-bin relative deviation measurement.
Smooths each channel (bin) with an exponential moving average, then computes the mean relative deviation of the current values from the smoothed values. Useful for detecting temporal instability in multi-dimensional signals (e.g., spectral bins, sensor arrays).
update(): O(N) Memory: N*T (one EMA state per channel)
SpectralVarianceImpl<float> sv(0.2f); // alpha=0.2, ~5 frame window float variance = sv.update(fftBins); // returns mean relative deviation
The alpha parameter controls the EMA speed:
The floor parameter prevents division by zero in near-silent channels. Channels below the floor are excluded from the deviation calculation.
Definition at line 29 of file spectral_variance_impl.h.
#include <spectral_variance_impl.h>
Inheritance diagram for fl::detail::SpectralVarianceImpl< T >:
Collaboration diagram for fl::detail::SpectralVarianceImpl< T >:Public Member Functions | |
| SpectralVarianceImpl (T alpha=T(0.2f), T floor=T(1e-4f)) | |
| void | reset () |
| Reset all internal state. | |
| void | setAlpha (T alpha) |
| Change the EMA alpha (tracking speed). | |
| void | setFloor (T floor) |
| Change the floor threshold for active channel detection. | |
| fl::size | size () const |
| Get the number of channels being tracked. | |
| T | update (fl::span< const T > bins) |
| Feed a new frame of multi-channel data. | |
| T | value () const |
| Get the last computed variance without updating. | |
Private Attributes | |
| T | mAlpha |
| T | mFloor |
| fl::vector< T > | mSmoothed |
| T | mVariance |