FastLED 3.9.15
Loading...
Searching...
No Matches

◆ calculateSpectralFlux()

float fl::audio::detector::MoodAnalyzer::calculateSpectralFlux ( const fft::Bins & fft,
const fft::Bins * prevFFT )
private

Definition at line 148 of file mood_analyzer.cpp.hpp.

148 {
149 if (!prevFFT || prevFFT->raw().size() != fft.raw().size()) {
150 return 0.0f;
151 }
152
153 float flux = 0.0f;
154 for (size_t i = 0; i < fft.raw().size(); i++) {
155 float diff = fft.raw()[i] - prevFFT->raw()[i];
156 flux += diff * diff;
157 }
158
159 return fl::sqrt(flux);
160}
AudioAnalyzeFFT1024 fft
constexpr enable_if< is_fixed_point< T >::value, T >::type sqrt(T x) FL_NOEXCEPT

References fl::audio::fft::Bins::raw(), and fl::sqrt().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: