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

Function leakageRatio

tests/profile/fft_cq_compare.cpp:135–147  ·  view source on GitHub ↗

Spectral leakage: fraction of total energy NOT in peak bin +/- 1

Source from the content-addressed store, hash-verified

133
134// Spectral leakage: fraction of total energy NOT in peak bin +/- 1
135static float leakageRatio(fl::span<const float> bins, int peak) {
136 float total = 0.0f;
137 float peakEnergy = 0.0f;
138 for (int i = 0; i < static_cast<int>(bins.size()); i++) {
139 float e = bins[i] * bins[i];
140 total += e;
141 if (i >= peak - 1 && i <= peak + 1) {
142 peakEnergy += e;
143 }
144 }
145 if (total <= 0.0f) return 1.0f;
146 return 1.0f - (peakEnergy / total);
147}
148
149struct AccuracyResult {
150 const char *modeName;

Callers 1

runAccuracyTestFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected