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

Method getMidEnergy

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

Source from the content-addressed store, hash-verified

119}
120
121float DropDetector::getMidEnergy(const fft::Bins& fft) const {
122 // Mid = middle 50% of bins (midrange frequencies)
123 int startBin = static_cast<int>(fft.raw().size() / 4);
124 int endBin = static_cast<int>(fft.raw().size() * 3 / 4);
125 float energy = 0.0f;
126 int count = 0;
127
128 for (int i = startBin; i < endBin; i++) {
129 energy += fft.raw()[i];
130 count++;
131 }
132
133 return (count > 0) ? energy / static_cast<float>(count) : 0.0f;
134}
135
136float DropDetector::getTrebleEnergy(const fft::Bins& fft) const {
137 // Treble = top 25% of bins (high frequencies)

Callers 3

FL_TEST_FILEFunction · 0.45

Calls 2

sizeMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected