Find the bin with the highest magnitude
| 120 | |
| 121 | // Find the bin with the highest magnitude |
| 122 | static 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 |
| 135 | static float leakageRatio(fl::span<const float> bins, int peak) { |