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

◆ calculateBeatAccent()

float fl::audio::detector::Downbeat::calculateBeatAccent ( const fft::Bins & fft,
float bassEnergy )
private

Definition at line 189 of file downbeat.cpp.hpp.

189 {
190 // Accent detection combines multiple factors:
191 // 1. Energy increase (stronger accent = more energy)
192 // 2. Bass energy (downbeats typically have more bass)
193 // 3. Spectral flux (onset strength)
194
195 // Energy increase relative to previous beat
196 float energyRatio = 1.0f;
197 if (mPreviousEnergy > 1e-6f) {
198 energyRatio = bassEnergy / mPreviousEnergy;
199 }
200
201 // Calculate overall energy
202 float totalEnergy = 0.0f;
203 for (size i = 0; i < fft.raw().size(); i++) {
204 totalEnergy += fft.raw()[i];
205 }
206 totalEnergy /= static_cast<float>(fft.raw().size());
207
208 // Bass ratio (downbeats typically have relatively more bass)
209 float bassRatio = 1.0f;
210 if (totalEnergy > 1e-6f) {
211 bassRatio = bassEnergy / totalEnergy;
212 }
213
214 // Combine factors (weighted average)
215 float accent = (energyRatio * 0.4f) + (bassRatio * 0.3f) + (totalEnergy * 0.3f);
216
217 return accent;
218}
AudioAnalyzeFFT1024 fft

References mPreviousEnergy.

Referenced by update().

+ Here is the caller graph for this function: