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

◆ calculateSpectralRolloff()

float fl::audio::detector::MoodAnalyzer::calculateSpectralRolloff ( const fft::Bins & fft,
float threshold = 0.85f )
private

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

126 {
127 float totalEnergy = 0.0f;
128
129 for (size_t i = 0; i < fft.raw().size(); i++) {
130 float magnitude = fft.raw()[i];
131 totalEnergy += magnitude * magnitude;
132 }
133
134 float energyThreshold = totalEnergy * threshold;
135 float cumulativeEnergy = 0.0f;
136
137 for (size_t i = 0; i < fft.raw().size(); i++) {
138 float magnitude = fft.raw()[i];
139 cumulativeEnergy += magnitude * magnitude;
140 if (cumulativeEnergy >= energyThreshold) {
141 return static_cast<float>(i) / fft.raw().size();
142 }
143 }
144
145 return 1.0f;
146}
AudioAnalyzeFFT1024 fft

Referenced by update().

+ Here is the caller graph for this function: