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

◆ calculateSpectralFlux()

float fl::audio::detector::TempoAnalyzer::calculateSpectralFlux ( const fft::Bins & fft)
private

Definition at line 133 of file tempo_analyzer.cpp.hpp.

133 {
134 // Focus on low-to-mid frequencies for beat detection
135 float flux = 0.0f;
136 size numBins = fl::min(static_cast<size>(8), fft.raw().size());
137 numBins = fl::min(numBins, mPreviousMagnitudes.size());
138
139 for (size i = 0; i < numBins; i++) {
140 float diff = fft.raw()[i] - mPreviousMagnitudes[i];
141 if (diff > 0.0f) {
142 flux += diff;
143 }
144 }
145
146 return flux / static_cast<float>(numBins);
147}
AudioAnalyzeFFT1024 fft
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71

References fl::min(), and mPreviousMagnitudes.

Referenced by update().

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