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

Method getTrebleEnergy

src/fl/audio/detector/drop.cpp.hpp:136–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136float DropDetector::getTrebleEnergy(const fft::Bins& fft) const {
137 // Treble = top 25% of bins (high frequencies)
138 int startBin = static_cast<int>(fft.raw().size() * 3 / 4);
139 float energy = 0.0f;
140 int count = 0;
141
142 for (fl::size i = startBin; i < fft.raw().size(); i++) {
143 energy += fft.raw()[i];
144 count++;
145 }
146
147 return (count > 0) ? energy / static_cast<float>(count) : 0.0f;
148}
149
150float DropDetector::calculateSpectralNovelty(float bass, float mid, float treble) const {
151 // Calculate how much the spectrum changed from previous frame

Callers 3

FL_TEST_FILEFunction · 0.45

Calls 2

sizeMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected