MCPcopy Create free account
hub / github.com/FastLED/FastLED / detectOnset

Method detectOnset

src/fl/audio/audio_reactive.cpp.hpp:799–813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

797}
798
799bool 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
815float SpectralFluxDetector::calculateSpectralFlux(span<const float, 16> currentBins, span<const float, 16> previousBins) {
816 float flux = 0.0f;

Callers 1

detectEnhancedBeatsMethod · 0.45

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected