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

Function peakBin

tests/profile/fft_cq_compare.cpp:122–132  ·  view source on GitHub ↗

Find the bin with the highest magnitude

Source from the content-addressed store, hash-verified

120
121// Find the bin with the highest magnitude
122static int peakBin(fl::span<const float> bins) {
123 int best = 0;
124 float bestVal = 0.0f;
125 for (int i = 0; i < static_cast<int>(bins.size()); i++) {
126 if (bins[i] > bestVal) {
127 bestVal = bins[i];
128 best = i;
129 }
130 }
131 return best;
132}
133
134// Spectral leakage: fraction of total energy NOT in peak bin +/- 1
135static float leakageRatio(fl::span<const float> bins, int peak) {

Callers 1

runAccuracyTestFunction · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected