| 797 | } |
| 798 | |
| 799 | bool SpectralFluxDetector::detectOnset(span<const float, 16> currentBins) { |
| 800 | float flux = calculateSpectralFlux(currentBins, span<const float, 16>(mPreviousMagnitudes.data(), 16)); |
| 801 | |
| 802 | #if SKETCH_HAS_LARGE_MEMORY |
| 803 | // Store flux in history for adaptive threshold calculation |
| 804 | mFluxHistory[mHistoryIndex] = flux; |
| 805 | mHistoryIndex = (mHistoryIndex + 1) % mFluxHistory.size(); |
| 806 | |
| 807 | float adaptiveThreshold = calculateAdaptiveThreshold(); |
| 808 | return flux > adaptiveThreshold; |
| 809 | #else |
| 810 | // Simple fixed threshold for memory-constrained platforms |
| 811 | return flux > mFluxThreshold; |
| 812 | #endif |
| 813 | } |
| 814 | |
| 815 | float SpectralFluxDetector::calculateSpectralFlux(span<const float, 16> currentBins, span<const float, 16> previousBins) { |
| 816 | float flux = 0.0f; |
no test coverage detected