--------------------------------------------------------------------------- Helper: energy concentration in peak ±1 bins (fraction of total energy) ---------------------------------------------------------------------------
| 68 | // Helper: energy concentration in peak ±1 bins (fraction of total energy) |
| 69 | // --------------------------------------------------------------------------- |
| 70 | static 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 |