Spectral leakage: fraction of total energy NOT in peak bin +/- 1
| 133 | |
| 134 | // Spectral leakage: fraction of total energy NOT in peak bin +/- 1 |
| 135 | static 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 | |
| 149 | struct AccuracyResult { |
| 150 | const char *modeName; |