MCPcopy Create free account
hub / github.com/FastLED/FastLED / calculateHighFreqEnergy

Method calculateHighFreqEnergy

src/fl/audio/detector/transient.cpp.hpp:85–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85float Transient::calculateHighFreqEnergy(const fft::Bins& fft) {
86 // Focus on mid-high to high frequencies (bins 4-15) for transient detection
87 // Low frequencies tend to have slower attack times
88 float energy = 0.0f;
89 size numBins = fft.raw().size();
90
91 // Weight higher frequencies more for transient detection
92 for (size i = 4; i < numBins; i++) {
93 float weight = static_cast<float>(i) / static_cast<float>(numBins);
94 energy += fft.raw()[i] * (1.0f + weight);
95 }
96
97 size validBins = (numBins > 4) ? (numBins - 4) : 1;
98 return energy / static_cast<float>(validBins);
99}
100
101float Transient::calculateEnergyFlux(float currentEnergy) {
102 // Calculate positive energy flux (increase in energy)

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected