FastLED 3.9.15
Loading...
Searching...
No Matches

◆ detectEnhancedBeats()

void fl::AudioReactive::detectEnhancedBeats ( fl::u32 currentTimeMs)
private

Definition at line 470 of file audio_reactive.cpp.

470 {
471 // Reset beat flags
472 mCurrentData.bassBeatDetected = false;
473 mCurrentData.midBeatDetected = false;
474 mCurrentData.trebleBeatDetected = false;
475
476 // Skip if enhanced beat detection is disabled
477 if (!mConfig.enableSpectralFlux && !mConfig.enableMultiBand) {
478 return;
479 }
480
481 // Need minimum time since last beat for enhanced detection too
482 if (currentTimeMs - mLastBeatTime < BEAT_COOLDOWN) {
483 return;
484 }
485
486 // Spectral flux-based beat detection
487 if (mConfig.enableSpectralFlux && mSpectralFluxDetector) {
488 bool onsetDetected = mSpectralFluxDetector->detectOnset(
489 mCurrentData.frequencyBins,
491 );
492
493 if (onsetDetected) {
494 // Enhance the traditional beat detection when spectral flux confirms
495 mCurrentData.beatDetected = true;
496 mLastBeatTime = currentTimeMs;
497 }
498 }
499
500 // Multi-band beat detection
501 if (mConfig.enableMultiBand) {
502 // Bass beat detection (bins 0-1)
503 if (mCurrentData.bassEnergy > mConfig.bassThreshold) {
504 mCurrentData.bassBeatDetected = true;
505 }
506
507 // Mid beat detection (bins 6-7)
508 if (mCurrentData.midEnergy > mConfig.midThreshold) {
509 mCurrentData.midBeatDetected = true;
510 }
511
512 // Treble beat detection (bins 14-15)
513 if (mCurrentData.trebleEnergy > mConfig.trebleThreshold) {
514 mCurrentData.trebleBeatDetected = true;
515 }
516 }
517}
fl::array< float, 16 > mPreviousMagnitudes
AudioReactiveConfig mConfig
fl::unique_ptr< SpectralFluxDetector > mSpectralFluxDetector
static constexpr fl::u32 BEAT_COOLDOWN

References BEAT_COOLDOWN, mConfig, mCurrentData, mLastBeatTime, mPreviousMagnitudes, and mSpectralFluxDetector.

Referenced by processSample().

+ Here is the caller graph for this function: