| 83 | } |
| 84 | |
| 85 | float Transient::calculateHighFreqEnergy(const fft::Bins& fft) { |
| 86 | // Focus on mid-high to high frequencies (bins 4-15) for transient detection |
| 87 | // Low frequencies tend to have slower attack times |
| 88 | float energy = 0.0f; |
| 89 | size numBins = fft.raw().size(); |
| 90 | |
| 91 | // Weight higher frequencies more for transient detection |
| 92 | for (size i = 4; i < numBins; i++) { |
| 93 | float weight = static_cast<float>(i) / static_cast<float>(numBins); |
| 94 | energy += fft.raw()[i] * (1.0f + weight); |
| 95 | } |
| 96 | |
| 97 | size validBins = (numBins > 4) ? (numBins - 4) : 1; |
| 98 | return energy / static_cast<float>(validBins); |
| 99 | } |
| 100 | |
| 101 | float Transient::calculateEnergyFlux(float currentEnergy) { |
| 102 | // Calculate positive energy flux (increase in energy) |