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

Function energyConcentration

tests/profile/audio/pitch_sweep_test.cpp:70–83  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Helper: energy concentration in peak ±1 bins (fraction of total energy) ---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

68// Helper: energy concentration in peak ±1 bins (fraction of total energy)
69// ---------------------------------------------------------------------------
70static float energyConcentration(fl::span<const float> bins, int peak) {
71 float total = 0.0f;
72 float peakEnergy = 0.0f;
73 for (int i = 0; i < static_cast<int>(bins.size()); i++) {
74 float e = bins[i] * bins[i];
75 total += e;
76 if (i >= peak - 1 && i <= peak + 1) {
77 peakEnergy += e;
78 }
79 }
80 if (total <= 0.0f)
81 return 0.0f;
82 return peakEnergy / total;
83}
84
85// ---------------------------------------------------------------------------
86// Mode / Window enum tables

Callers 1

runSweepFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected