Repository navigation
feat(audio): TempoAnalyzer confidence fades in silence (#2253) - #2311
Conversation
Composes a fl::audio::SilenceEnvelope (tau=2.0s, target=0) into TempoAnalyzer so that the BPM confidence metric decays smoothly during silence instead of persisting on stale hypotheses. The raw BPM estimate itself is NOT gated — last-known tempo is preserved across silence so beat sync resumes seamlessly when audio returns. Tau=2s matches the natural persistence of musical tempo; snapping faster feels wrong. dt is derived from context timestamp deltas so the envelope's first-order response is frame-rate independent. When context->isSilent() is false the envelope is a strict pass-through, preserving existing tempo-detection behavior for users who haven't enabled NoiseFloorTracker. Adds two integration tests: one drives 15 beats of synthetic 120 BPM onsets and confirms confidence > 0.3, then asserts confidence < 0.05 after ~5s of silence while BPM is unchanged; the other verifies pass-through when isSilent=false. User-visible impact: LED effects keyed to BPM confidence (rhythmic-effect gating) stop driving rhythm when music stops, instead of staying "in rhythm" for 5-10+ seconds on stale onset hypotheses. Part 4/4 of #2253 silence-gate rollout. Builds on #2306. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📊 Header Compilation PerformanceTotal Time: 1000.08ms Top 5 Slowest Headers
Warnings
Full Report |
Summary
TempoAnalyzer::mConfidencethrough aSilenceEnvelope(tau=2.0s, target=0) so rhythmic-effect confidence decays smoothly during silence instead of clinging to stale onset hypotheses for 5–10+ seconds.!isSilentis a strict pass-through, preserving behavior for users who haven't opted intoNoiseFloorTracker.Part 4/4 of #2253 silence-gate rollout. Builds on #2306 (Phase 1 foundations).
Design notes
getConfidence()/getBPM()/ callback semantics are unchanged.Test plan
bash test fl_audio --debugpasses (211/211 doctest cases).bash lint src/fl/audio/detector/tempo_analyzer.{h,cpp.hpp} tests/fl/audio/detector/tempo_analyzer.hppclean.TempoAnalyzer - confidence fades in silence, BPM preserved:context->setSilent(true)for ~5s → assert confidence < 0.05 AND BPM == pre-silence value.TempoAnalyzer - confidence pass-through when not silentcovers the audio-path no-op.Scope-limited to tempo_analyzer; parallel agents are handling Vibe (PR-C) and Reactive spectral (PR-D).
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests