Skip to content

feat(audio): Reactive spectral metrics gate in silence (#2253) - #2309

Merged
zackees merged 1 commit into
masterfrom
feat/audio-silence-gate-reactive-spectral
Apr 18, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/audio-silence-gate-reactive-spectral

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Part 3/4 of the #2253 silence-gate rollout. Gates three spectral Data fields on fl::audio::Reactive through SilenceEnvelope so they decay to zero when the pipeline signals silence.

  • Data::dominantFrequency — previously the FFT argmax latched onto arbitrary bins during silence (numerical noise floor).
  • Data::magnitude — companion to dominantFrequency; same issue.
  • Data::spectralFlux — could fire false onsets on noise-floor flicker.

All three now pass through SilenceEnvelope (tau=0.2s) inside processSample(). During audio (Context::isSilent() == false) the envelope is a strict pass-through; during silence it exponentially decays toward zero. Frame-rate-independent dt comes from computeAudioDt(pcm.size(), sampleRate). No behavior change for users who haven't opted into enableNoiseFloorTracking.

Tau=0.2s per the design-doc recommendation: spectral metrics are brittle and should snap to zero within ~1 s of silence onset. The existing argmax in mapFFTBinsToFrequencyChannels() is untouched — envelopes post-process its output.

Builds on #2306 (Phase 1: Context::isSilent() + SilenceEnvelope). Out-of-scope for this PR: Vibe (PR-C, parallel) and TempoAnalyzer (PR-E, next).

Test plan

  • New: audio::Reactive - spectral metrics decay to zero on silence (FastLED#2253) — drives 1 s of 440 Hz sine, then 1 s of zero-PCM, asserts all three fields < 0.01 after silence.
  • New: audio::Reactive - spectral metrics are pass-through during loud audio (FastLED#2253) — confirms unchanged behavior during live audio (dominant frequency in audible range, magnitude > 0).
  • bash test fl_audio --debug passes (ASAN/LSAN/UBSAN clean).
  • bash lint clean on all three touched files.
  • All pre-existing fl_audio tests continue to pass (no behavior change when NFT not enabled).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Audio reactive spectral analysis now includes refined silence handling. Dominant frequency, magnitude, and spectral flux metrics decay smoothly when audio drops below the noise floor, improving stability during quiet passages.
  • Tests

    • Added test coverage validating spectral metric decay behavior during silence and normal pass-through operation during audio.

Adopts SilenceEnvelope for three spectral Data fields on Reactive:
dominantFrequency, magnitude, and spectralFlux. During silence the
envelope (tau=0.2s) exponentially decays each metric toward zero,
stopping the FFT noise-floor argmax from locking onto arbitrary bins
and preventing false onset detections. During audio the envelope is
strict pass-through, so existing users who have not enabled
NoiseFloorTracker see no behavior change — gating is strictly opt-in.

Tau=0.2s chosen because FFT noise is brittle and spectral metrics
should snap to zero within ~1 second of silence onset. The existing
argmax in mapFFTBinsToFrequencyChannels() is unchanged; envelopes
post-process its output inside processSample() where dt is computed
via computeAudioDt(pcm.size(), sampleRate) for frame-rate independence.

Part 3/4 of #2253 silence-gate rollout. Builds on #2306.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6e1c5c07-508e-4907-b73a-03cb4fd65c5f

📥 Commits

Reviewing files that changed from the base of the PR and between 3288027 and 06ac994.

📒 Files selected for processing (3)
  • src/fl/audio/audio_reactive.cpp.hpp
  • src/fl/audio/audio_reactive.h
  • tests/fl/audio/audio_reactive.cpp

📝 Walkthrough

Walkthrough

The changes add silence-gating functionality to the audio reactive system by introducing three SilenceEnvelope instances that exponentially decay spectral metrics (dominant frequency, magnitude, spectral flux) during detected silence periods. Envelopes are initialized in the constructor, reset in begin(), and updated in processSample() following spectral analysis. Tests verify decay behavior during silence and pass-through during audio.

Changes

Cohort / File(s) Summary
Silence Envelope Integration
src/fl/audio/audio_reactive.h, src/fl/audio/audio_reactive.cpp.hpp
Added three private SilenceEnvelope members (mDominantFrequencyEnvelope, mMagnitudeEnvelope, mSpectralFluxEnvelope) with decay configuration (decayTauSeconds = 0.2f, targetValue = 0.0f). Initialization in constructor, reset in begin(), and gating logic in processSample() that applies exponential decay to spectral metrics when silence is detected via Context::isSilent().
Test Coverage
tests/fl/audio/audio_reactive.cpp
Added two test cases: one verifying spectral metrics decay to zero during silence with noise floor tracking enabled; another confirming metrics remain pass-through during loud audio (non-silent) conditions.

Sequence Diagram

sequenceDiagram
    participant Sample as Audio Sample
    participant Reactive as Reactive
    participant Spectral as Spectral Analysis
    participant Context as Context
    participant Envelope as SilenceEnvelope
    
    Sample->>Reactive: processSample(pcm_buffer)
    Reactive->>Spectral: updateSpectralFlux()
    Spectral->>Reactive: returns dominantFreq, magnitude, flux
    Reactive->>Context: isSilent()
    Context-->>Reactive: boolean (silent status)
    
    alt Silence Detected
        Reactive->>Envelope: update(silent=true, currentValue, dt)
        Envelope->>Envelope: exponential decay
        Envelope-->>Reactive: decayed_value
        Reactive->>Reactive: mCurrentData.dominantFrequency = decayed_value
        Reactive->>Reactive: mCurrentData.magnitude = decayed_value
        Reactive->>Reactive: mCurrentData.spectralFlux = decayed_value
    else Audio Present
        Envelope->>Envelope: update(silent=false, currentValue, dt)
        Envelope-->>Reactive: pass-through currentValue
        Reactive->>Reactive: mCurrentData.* = currentValue
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Silence falls, the envelopes unfold,
Spectral whispers fade and gently decay,
Three guardians weave their tapers gold,
When quiet reigns, the metrics softly stray! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/audio-silence-gate-reactive-spectral

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit ed3b452 into master Apr 18, 2026
63 of 85 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📊 Header Compilation Performance

Total Time: 1005.10ms

Top 5 Slowest Headers

  1. FastLED.h - 760.68ms
  2. fl/fastled.h - 322.48ms
  3. fl/task/executor.h - 246.43ms
  4. crgb.h - 177.44ms
  5. fl/gfx/crgb.h - 176.17ms

Warnings

⚠️ Header FastLED.h exceeds 150ms (760.7ms)
⚠️ Header fl/fastled.h exceeds 150ms (322.5ms)
⚠️ Header fl/task/executor.h exceeds 150ms (246.4ms)
⚠️ Header crgb.h exceeds 150ms (177.4ms)
⚠️ Header fl/gfx/crgb.h exceeds 150ms (176.2ms)
⚠️ Header fl/math/ease.h exceeds 150ms (171.9ms)
⚠️ Header fl/math/fixed_point.h exceeds 150ms (170.0ms)
⚠️ Header fl/task/scheduler.h exceeds 50ms (130.9ms)
⚠️ Header fl/stl/singleton.h exceeds 50ms (121.8ms)
⚠️ Header fl/stl/thread_local.h exceeds 50ms (121.1ms)
⚠️ Header fl/stl/thread.h exceeds 50ms (120.0ms)
⚠️ Header platforms/thread.h exceeds 50ms (119.9ms)
⚠️ Header platforms/stub/thread_stub.h exceeds 50ms (119.8ms)
⚠️ Header platforms/stub/thread_stub_stl.h exceeds 50ms (119.8ms)
⚠️ Header fl/ui.h exceeds 50ms (105.8ms)
⚠️ Header fl/task/promise.h exceeds 50ms (103.2ms)
⚠️ Header fl/stl/json.h exceeds 50ms (66.0ms)
⚠️ Header fl/stl/function.h exceeds 50ms (60.5ms)
⚠️ Header fl/stl/json/types.h exceeds 50ms (51.7ms)
⚠️ Header platforms.h exceeds 50ms (50.7ms)
⚠️ Header platforms/stub/fastled_stub.h exceeds 50ms (50.6ms)
⚠️ Template instantiation time is high (52.2%)

Full Report
================================================================================
FASTLED COMPILATION PERFORMANCE REPORT
================================================================================
Generated: 2026-04-18 15:46:57
Compiler: clang++-17
File: ci/perf/test_compile.cpp

SUMMARY
--------------------------------------------------------------------------------
Total Compilation Time:    1,437.56 ms
Frontend Time:             14.38 ms (1.0%)
Backend Time:              79.70 ms (5.5%)

COMPILATION PHASES
--------------------------------------------------------------------------------
Source                     8683.42 ms (604.0%)
Templates                   532.67 ms ( 37.1%)

FASTLED HEADERS (Level 1 - Direct Includes)
--------------------------------------------------------------------------------
  1091.3 ms - FastLED.h (SLOW)
   506.0 ms - fl/task/executor.h (SLOW)
   384.9 ms - fl/fastled.h (SLOW)
   281.4 ms - fl/task/scheduler.h (SLOW)
   269.0 ms - fl/stl/singleton.h (SLOW)
   268.4 ms - fl/stl/thread_local.h (SLOW)
   267.2 ms - fl/stl/thread.h (SLOW)
   267.1 ms - platforms/thread.h (SLOW)
   267.1 ms - platforms/stub/thread_stub.h (SLOW)
   267.0 ms - platforms/stub/thread_stub_stl.h (SLOW)
   218.5 ms - crgb.h (SLOW)
   217.3 ms - fl/gfx/crgb.h (SLOW)
   213.1 ms - fl/math/ease.h (SLOW)
   211.8 ms - fl/task/promise.h (SLOW)
   211.2 ms - fl/math/fixed_point.h (SLOW)
   162.1 ms - fl/stl/function.h (SLOW)
   105.9 ms - fl/ui.h (SLOW)
    92.2 ms - fl/math/fixed_point/s4x12.h (SLOW)
    78.6 ms - fl/stl/vector.h (SLOW)
    75.5 ms - fl/math/sin32.h (SLOW)

FASTLED HEADERS (Nested Includes - Up to 10 Levels)
--------------------------------------------------------------------------------
FastLED.h (1091.3ms)
  ├─  506.0 ms - fl/task/executor.h
  │ ├─  281.4 ms - fl/task/scheduler.h
  │ │ ├─  269.0 ms - fl/stl/singleton.h
  │ │ │ └─  268.4 ms - fl/stl/thread_local.h
  │ │ │   └─  267.2 ms - fl/stl/thread.h
  │ │ │     └─  267.1 ms - platforms/thread.h
  │ │ │       └─  267.1 ms - platforms/stub/thread_stub.h
  │ │ │         └─  267.0 ms - platforms/stub/thread_stub_stl.h
  │ │ │           └─  261.7 ms - thread
  │ │ │             ├─  151.0 ms - std_thread.h
  │ │ │             └─   97.3 ms - this_thread_sleep.h
  │ │ └─   11.5 ms - fl/task/task.h
  │ │   └─    4.3 ms - fl/trace.h
  │ │     ├─    2.8 ms - fl/stl/chrono.h
  │ │     └─    1.1 ms - fl/stl/tuple.h
  │ ├─  211.8 ms - fl/task/promise.h
  │ │ ├─  162.1 ms - fl/stl/function.h
  │ │ │ ├─   78.6 ms - fl/stl/vector.h
  │ │ │ │ ├─   48.9 ms - fl/math/math.h
  │ │ │ │ │ └─   42.1 ms - fl/stl/undef.h
  │ │ │ │ │   └─   64.8 ms - stdlib.h
  │ │ │ │ │     ├─   34.0 ms - cstdlib
  │ │ │ │ │     │ ├─   64.8 ms - stdlib.h
  │ │ │ │ │     │ │ ├─   34.0 ms - cstdlib
  │ │ │ │ │     │ │ └─   11.3 ms - types.h
  │ │ │ │ │     │ └─    0.6 ms - std_abs.h
  │ │ │ │ │     └─   11.3 ms - types.h
  │ │ │ │ │       ├─   11.3 ms - types.h
  │ │ │ │ │       │ ├─   11.3 ms - types.h
  │ │ │ │ │       │ ├─    2.6 ms - pthreadtypes.h
  │ │ │ │ │       │ ├─    2.5 ms - select.h
  │ │ │ │ │       │ └─    2.2 ms - endian.h
  │ │ │ │ │       ├─    2.6 ms - pthreadtypes.h
  │ │ │ │ │       │ └─    2.0 ms - thread-shared-types.h
  │ │ │ │ │       ├─    2.5 ms - select.h
  │ │ │ │ │       │ └─    0.7 ms - sigset_t.h
  │ │ │ │ │       └─    2.2 ms - endian.h
  │ │ │ │ │         └─    0.6 ms - byteswap.h
  │ │ │ │ ├─   16.2 ms - fl/stl/allocator.h
  │ │ │ │ │ └─   11.2 ms - fl/stl/bitset.h
  │ │ │ │ │   └─    7.5 ms - fl/stl/bitset_dynamic.h
  │ │ │ │ │     └─    2.5 ms - fl/stl/unique_ptr.h
  │ │ │ │ │       └─    0.9 ms - fl/stl/utility.h
  │ │ │ │ ├─    4.2 ms - fl/stl/initializer_list.h
  │ │ │ │ ├─    2.4 ms - fl/stl/basic_vector.h
  │ │ │ │ └─    0.6 ms - fl/stl/functional.h
  │ │ │ ├─   38.8 ms - fl/stl/variant.h
  │ │ │ │ └─   37.1 ms - fl/stl/new.h
  │ │ │ │   └─   37.1 ms - platforms/new.h
  │ │ │ │     └─   37.1 ms - platforms/shared/new.h
  │ │ │ │       └─   28.7 ms - new
  │ │ │ │         ├─   15.3 ms - c++config.h
  │ │ │ │         │ └─    3.5 ms - os_defines.h
  │ │ │ │         └─    0.6 ms - version.h
  │ │ │ ├─   32.0 ms - fl/stl/shared_ptr.h
  │ │ │ │ ├─   21.5 ms - fl/stl/type_traits.h
  │ │ │ │ │ └─   16.5 ms - fl/stl/move.h
  │ │ │ │ ├─    6.1 ms - fl/stl/atomic.h
  │ │ │ │ │ └─    5.4 ms - platforms/atomic.h
  │ │ │ │ │   └─    5.3 ms - platforms/shared/atomic.h
  │ │ │ │ └─    0.7 ms - fl/stl/bit_cast.h
  │ │ │ ├─    4.1 ms - fl/stl/compiler_control.h
  │ │ │ └─    3.8 ms - fl/stl/algorithm.h
  │ │ │   └─    1.6 ms - fl/math/random.h
  │ │ │     └─    0.8 ms - fl/math/random8.h
  │ │ └─   42.5 ms - fl/stl/string.h
  │ │   ├─   11.2 ms - fl/stl/basic_string.h
  │ │   │ ├─    0.9 ms - fl/stl/not_null.h
  │ │   │ └─    0.8 ms - fl/stl/iterator.h
  │ │   ├─    7.1 ms - fl/stl/span.h
  │ │   │ └─    3.0 ms - fl/math/geometry.h
  │ │   ├─    4.4 ms - fl/stl/string_view.h
  │ │   └─    1.3 ms - fl/stl/optional.h
  │ ├─   10.4 ms - platforms/await.h
  │ │ └─   10.0 ms - platforms/coroutine_runtime.h
  │ │   └─    8.4 ms - fl/system/engine_events.h
  │ │     ├─    4.2 ms - fl/math/screenmap.h
  │ │     │ └─    3.0 ms - fl/stl/flat_map.h
  │ │     └─    2.8 ms - fl/math/xymap.h
  │ │       └─    0.7 ms - fl/math/lut.h
  │ └─    1.0 ms - fl/task/promise_result.h
  ├─  384.9 ms - fl/fastled.h
  │ ├─  218.5 ms - crgb.h
  │ │ ├─  217.3 ms - fl/gfx/crgb.h
  │ │ │ └─  213.1 ms - fl/math/ease.h
  │ │ │   └─  211.2 ms - fl/math/fixed_point.h
  │ │ │     ├─   92.2 ms - fl/math/fixed_point/s4x12.h
  │ │ │     │ ├─   75.5 ms - fl/math/sin32.h
  │ │ │     │ │ └─   72.9 ms - fl/math/simd.h
  │ │ │     │ │   └─   72.4 ms - fl/math/simd/types.h
  │ │ │     │ │     └─   72.1 ms - platforms/simd.h
  │ │ │     │ ├─    0.9 ms - fl/math/fixed_point/traits.h
  │ │ │     │ └─    0.6 ms - fl/math/fixed_point/isqrt.h
  │ │ │     ├─   14.8 ms - fl/math/fixed_point/s8x24.h
  │ │ │     ├─   14.7 ms - fl/math/fixed_point/s8x8.h
  │ │ │     ├─   14.6 ms - fl/math/fixed_point/s16x16.h
  │ │ │     └─   14.5 ms - fl/math/fixed_point/s24x8.h
  │ │ └─    0.8 ms - chsv.h
  │ │   └─    0.7 ms - fl/gfx/hsv.h
  │ ├─   73.6 ms - platforms.h
  │ │ └─   73.6 ms - platforms/stub/fastled_stub.h
  │ │   ├─   40.8 ms - platforms/stub/fastspi_stub.h
  │ │   │ └─   40.7 ms - platforms/stub/fastspi_stub_generic.h
  │ │   │   ├─   34.8 ms - platforms/shared/active_strip_data/active_strip_data.h
  │ │   │   │ └─   32.7 ms - fl/id_tracker.h
  │ │   │   │   └─   31.7 ms - fl/stl/mutex.h
  │ │   │   │     └─   31.6 ms - platforms/mutex.h
  │ │   │   │       └─   31.5 ms - platforms/stub/mutex_stub.h
  │ │   │   └─    5.5 ms - platforms/shared/active_strip_tracker/active_strip_tracker.h
  │ │   └─   32.7 ms - platforms/stub/clockless_stub.h
  │ │     └─   32.7 ms - platforms/stub/clockless_channel_stub.h
  │ │       ├─   11.8 ms - fl/channels/data.h
  │ │       │ └─    8.8 ms - fl/channels/config.h
  │ │       │   ├─    1.8 ms - fl/chipsets/chipset_timing_config.h
  │ │       │   │ └─    1.2 ms - fl/chipsets/led_timing.h
  │ │       │   └─    1.4 ms - fl/chipsets/spi.h
  │ │       ├─   11.1 ms - fl/system/log.h
  │ │       │ └─   10.6 ms - fl/stl/strstream.h
  │ │       ├─    2.3 ms - fl/channels/manager.h
  │ │       ├─    1.4 ms - fl/stl/weak_ptr.h
  │ │       └─    1.0 ms - fl/channels/driver.h
  │ ├─   35.3 ms - colorutils.h
  │ │ └─   34.4 ms - fl/gfx/colorutils.h
  │ │   ├─    7.6 ms - fl/gfx/blur.h
  │ │   │ └─    4.1 ms - fl/gfx/canvas.h
  │ │   │   └─    2.5 ms - fl/math/alpha.h
  │ │   └─    2.7 ms - fl/gfx/fill.h
  │ ├─   19.9 ms - pixel_controller.h
  │ │ ├─   14.2 ms - pixel_iterator.h
  │ │ │ └─   14.1 ms - fl/chipsets/encoders/pixel_iterator.h
  │ │ │   ├─    4.0 ms - fl/chipsets/encoders/apa102.h
  │ │ │   │ └─    3.1 ms - fl/chipsets/encoders/encoder_utils.h
  │ │ │   │   └─    2.5 ms - fl/gfx/gamma_lut.h
  │ │ │   ├─    3.9 ms - fl/chipsets/encoders/pixel_iterator_adapters.h
  │ │ │   ├─    0.8 ms - fl/chipsets/encoders/sk9822.h
  │ │ │   └─    0.7 ms - fl/chipsets/encoders/hd108.h
  │ │ └─    2.4 ms - rgbw.h
  │ │   └─    2.2 ms - fl/gfx/rgbw.h
  │ └─   18.2 ms - pixeltypes.h
  │   ├─   15.1 ms - lib8tion.h
  │   │ ├─    7.6 ms - fl/math/math8.h
  │   │ │ ├─    3.9 ms - fl/math/intmap.h
  │   │ │ │ └─    3.1 ms - platforms/intmap.h
  │   │ │ ├─    2.0 ms - fl/math/scale8.h
  │   │ │ │ └─    1.9 ms - platforms/scale8.h
  │   │ │ │   └─    0.8 ms - platforms/shared/scale8.h
  │   │ │ └─    1.6 ms - platforms/math8.h
  │   │ │   └─    1.2 ms - platforms/shared/math8.h
  │   │ └─    1.6 ms - fl/math/beat.h
  │   │   └─    0.8 ms - fl/math/trig8.h
  │   │     └─    0.8 ms - platforms/trig8.h
  │   │       └─    0.7 ms - platforms/shared/trig8.h
  │   └─    2.8 ms - crgb.hpp
  ├─  105.9 ms - fl/ui.h
  │ ├─   66.9 ms - fl/stl/json.h
  │ │ └─   52.6 ms - fl/stl/json/types.h
  │ │   └─    6.2 ms - fl/stl/limits.h
  │ ├─    9.7 ms - fl/ui_impl.h
  │ │ └─    9.1 ms - platforms/ui_defs.h
  │ │   ├─    2.0 ms - platforms/shared/ui/json/audio.h
  │ │   │ └─    0.9 ms - platforms/shared/ui/json/audio_internal.h
  │ │   ├─    1.4 ms - platforms/shared/ui/json/button.h
  │ │   │ └─    0.6 ms - platforms/shared/ui/json/ui_internal.h
  │ │   ├─    0.9 ms - platforms/shared/ui/json/checkbox.h
  │ │   ├─    0.8 ms - platforms/shared/ui/json/help.h
  │ │   └─    0.8 ms - platforms/shared/ui/json/number_field.h
  │ └─    5.7 ms - fl/stl/url.h
  ├─   25.2 ms - chipsets.h
  │ ├─   10.4 ms - fl/chipsets/ucs7604.h
  │ │ └─    7.8 ms - fl/chipsets/encoders/ucs7604.h
  │ ├─    5.9 ms - fl/chipsets/apa102.h
  │ ├─    1.5 ms - fl/chipsets/lpd880x.h
  │ ├─    0.9 ms - fl/chipsets/encoders/ws2816.h
  │ └─    0.7 ms - fl/chipsets/p9813.h
  └─   20.3 ms - fl/audio/audio_processor.h
    ├─    5.2 ms - fl/audio/audio_context.h
    │ └─    1.5 ms - fl/audio/fft/fft.h
    ├─    1.6 ms - fl/audio/detector/vibe.h
    └─    0.8 ms - fl/audio/signal_conditioner.h
fl/task/executor.h (506.0ms)
  ├─  281.4 ms - fl/task/scheduler.h
  │ ├─  269.0 ms - fl/stl/singleton.h
  │ │ └─  268.4 ms - fl/stl/thread_local.h
  │ │   └─  267.2 ms - fl/stl/thread.h
  │ │     └─  267.1 ms - platforms/thread.h
  │ │       └─  267.1 ms - platforms/stub/thread_stub.h
  │ │         └─  267.0 ms - platforms/stub/thread_stub_stl.h
  │ │           └─  261.7 ms - thread
  │ │             ├─  151.0 ms - std_thread.h
  │ │             │ ├─   51.7 ms - tuple
  │ │             │ ├─   25.2 ms - iosfwd
  │ │             │ ├─   18.7 ms - refwrap.h
  │ │             │ ├─   12.5 ms - gthr.h
  │ │             │ └─    6.7 ms - unique_ptr.h
  │ │             └─   97.3 ms - this_thread_sleep.h
  │ │               ├─   85.7 ms - chrono.h
  │ │               └─    2.9 ms - cerrno
  │ └─   11.5 ms - fl/task/task.h
  │   └─    4.3 ms - fl/trace.h
  │     ├─    2.8 ms - fl/stl/chrono.h
  │     └─    1.1 ms - fl/stl/tuple.h
  ├─  211.8 ms - fl/task/promise.h
  │ ├─  162.1 ms - fl/stl/function.h
  │ │ ├─   78.6 ms - fl/stl/vector.h
  │ │ │ ├─   48.9 ms - fl/math/math.h
  │ │ │ │ └─   42.1 ms - fl/stl/undef.h
  │ │ │ │   └─   64.8 ms - stdlib.h
  │ │ │ │     ├─   34.0 ms - cstdlib
  │ │ │ │     │ ├─   64.8 ms - stdlib.h
  │ │ │ │     │ │ ├─   34.0 ms - cstdlib
  │ │ │ │     │ │ │ ├─   64.8 ms - stdlib.h
  │ │ │ │     │ │ │ └─    0.6 ms - std_abs.h
  │ │ │ │     │ │ └─   11.3 ms - types.h
  │ │ │ │     │ │   ├─   11.3 ms - types.h
  │ │ │ │     │ │   ├─    2.6 ms - pthreadtypes.h
  │ │ │ │     │ │   ├─    2.5 ms - select.h
  │ │ │ │     │ │   └─    2.2 ms - endian.h
  │ │ │ │     │ └─    0.6 ms - std_abs.h
  │ │ │ │     └─   11.3 ms - types.h
  │ │ │ │       ├─   11.3 ms - types.h
  │ │ │ │       │ ├─   11.3 ms - types.h
  │ │ │ │       │ │ ├─   11.3 ms - types.h
  │ │ │ │       │ │ ├─    2.6 ms - pthreadtypes.h
  │ │ │ │       │ │ ├─    2.5 ms - select.h
  │ │ │ │       │ │ └─    2.2 ms - endian.h
  │ │ │ │       │ ├─    2.6 ms - pthreadtypes.h
  │ │ │ │       │ │ └─    2.0 ms - thread-shared-types.h
  │ │ │ │       │ ├─    2.5 ms - select.h
  │ │ │ │       │ │ └─    0.7 ms - sigset_t.h
  │ │ │ │       │ └─    2.2 ms - endian.h
  │ │ │ │       │   └─    0.6 ms - byteswap.h
  │ │ │ │       ├─    2.6 ms - pthreadtypes.h
  │ │ │ │       │ └─    2.0 ms - thread-shared-types.h
  │ │ │ │       ├─    2.5 ms - select.h
  │ │ │ │       │ └─    0.7 ms - sigset_t.h
  │ │ │ │       └─    2.2 ms - endian.h
  │ │ │ │         └─    0.6 ms - byteswap.h
  │ │ │ ├─   16.2 ms - fl/stl/allocator.h
  │ │ │ │ └─   11.2 ms - fl/stl/bitset.h
  │ │ │ │   └─    7.5 ms - fl/stl/bitset_dynamic.h
  │ │ │ │     └─    2.5 ms - fl/stl/unique_ptr.h
  │ │ │ │       └─    0.9 ms - fl/stl/utility.h
  │ │ │ ├─    4.2 ms - fl/stl/initializer_list.h
  │ │ │ ├─    2.4 ms - fl/stl/basic_vector.h
  │ │ │ └─    0.6 ms - fl/stl/functional.h
  │ │ ├─   38.8 ms - fl/stl/variant.h
  │ │ │ └─   37.1 ms - fl/stl/new.h
  │ │ │   └─   37.1 ms - platforms/new.h
  │ │ │     └─   37.1 ms - platforms/shared/new.h
  │ │ │       └─   28.7 ms - new
  │ │ │         ├─   15.3 ms - c++config.h
  │ │ │         │ └─    3.5 ms - os_defines.h
  │ │ │         │   └─    3.2 ms - features.h
  │ │ │         └─    0.6 ms - version.h
  │ │ ├─   32.0 ms - fl/stl/shared_ptr.h
  │ │ │ ├─   21.5 ms - fl/stl/type_traits.h
  │ │ │ │ └─   16.5 ms - fl/stl/move.h
  │ │ │ ├─    6.1 ms - fl/stl/atomic.h
  │ │ │ │ └─    5.4 ms - platforms/atomic.h
  │ │ │ │   └─    5.3 ms - platforms/shared/atomic.h
  │ │ │ └─    0.7 ms - fl/stl/bit_cast.h
  │ │ ├─    4.1 ms - fl/stl/compiler_control.h
  │ │ └─    3.8 ms - fl/stl/algorithm.h
  │ │   └─    1.6 ms - fl/math/random.h
  │ │     └─    0.8 ms - fl/math/random8.h
  │ └─   42.5 ms - fl/stl/string.h
  │   ├─   11.2 ms - fl/stl/basic_string.h
  │   │ ├─    0.9 ms - fl/stl/not_null.h
  │   │ └─    0.8 ms - fl/stl/iterator.h
  │   ├─    7.1 ms - fl/stl/span.h
  │   │ └─    3.0 ms - fl/math/geometry.h
  │   ├─    4.4 ms - fl/stl/string_view.h
  │   └─    1.3 ms - fl/stl/optional.h
  ├─   10.4 ms - platforms/await.h
  │ └─   10.0 ms - platforms/coroutine_runtime.h
  │   └─    8.4 ms - fl/system/engine_events.h
  │     ├─    4.2 ms - fl/math/screenmap.h
  │     │ └─    3.0 ms - fl/stl/flat_map.h
  │     └─    2.8 ms - fl/math/xymap.h
  │       └─    0.7 ms - fl/math/lut.h
  └─    1.0 ms - fl/task/promise_result.h
fl/fastled.h (384.9ms)
  ├─  218.5 ms - crgb.h
  │ ├─  217.3 ms - fl/gfx/crgb.h
  │ │ └─  213.1 ms - fl/math/ease.h
  │ │   └─  211.2 ms - fl/math/fixed_point.h
  │ │     ├─   92.2 ms - fl/math/fixed_point/s4x12.h
  │ │     │ ├─   75.5 ms - fl/math/sin32.h
  │ │     │ │ └─   72.9 ms - fl/math/simd.h
  │ │     │ │   └─   72.4 ms - fl/math/simd/types.h
  │ │     │ │     └─   72.1 ms - platforms/simd.h
  │ │     │ │       └─   72.0 ms - platforms/shared/simd_x86.hpp
  │ │     │ ├─    0.9 ms - fl/math/fixed_point/traits.h
  │ │     │ └─    0.6 ms - fl/math/fixed_point/isqrt.h
  │ │     ├─   14.8 ms - fl/math/fixed_point/s8x24.h
  │ │     ├─   14.7 ms - fl/math/fixed_point/s8x8.h
  │ │     ├─   14.6 ms - fl/math/fixed_point/s16x16.h
  │ │     └─   14.5 ms - fl/math/fixed_point/s24x8.h
  │ └─    0.8 ms - chsv.h
  │   └─    0.7 ms - fl/gfx/hsv.h
  ├─   73.6 ms - platforms.h
  │ └─   73.6 ms - platforms/stub/fastled_stub.h
  │   ├─   40.8 ms - platforms/stub/fastspi_stub.h
  │   │ └─   40.7 ms - platforms/stub/fastspi_stub_generic.h
  │   │   ├─   34.8 ms - platforms/shared/active_strip_data/active_strip_data.h
  │   │   │ └─   32.7 ms - fl/id_tracker.h
  │   │   │   └─   31.7 ms - fl/stl/mutex.h
  │   │   │     └─   31.6 ms - platforms/mutex.h
  │   │   │       └─   31.5 ms - platforms/stub/mutex_stub.h
  │   │   │         └─   31.5 ms - platforms/stub/mutex_stub_stl.h
  │   │   └─    5.5 ms - platforms/shared/active_strip_tracker/active_strip_tracker.h
  │   └─   32.7 ms - platforms/stub/clockless_stub.h
  │     └─   32.7 ms - platforms/stub/clockless_channel_stub.h
  │       ├─   11.8 ms - fl/channels/data.h
  │       │ └─    8.8 ms - fl/channels/config.h
  │       │   ├─    1.8 ms - fl/chipsets/chipset_timing_config.h
  │       │   │ └─    1.2 ms - fl/chipsets/led_timing.h
  │       │   └─    1.4 ms - fl/chipsets/spi.h
  │       ├─   11.1 ms - fl/system/log.h
  │       │ └─   10.6 ms - fl/stl/strstream.h
  │       ├─    2.3 ms - fl/channels/manager.h
  │       ├─    1.4 ms - fl/stl/weak_ptr.h
  │       └─    1.0 ms - fl/channels/driver.h
  ├─   35.3 ms - colorutils.h
  │ └─   34.4 ms - fl/gfx/colorutils.h
  │   ├─    7.6 ms - fl/gfx/blur.h
  │   │ └─    4.1 ms - fl/gfx/canvas.h
  │   │   └─    2.5 ms - fl/math/alpha.h
  │   └─    2.7 ms - fl/gfx/fill.h
  ├─   19.9 ms - pixel_controller.h
  │ ├─   14.2 ms - pixel_iterator.h
  │ │ └─   14.1 ms - fl/chipsets/encoders/pixel_iterator.h
  │ │   ├─    4.0 ms - fl/chipsets/encoders/apa102.h
  │ │   │ └─    3.1 ms - fl/chipsets/encoders/encoder_utils.h
  │ │   │   └─    2.5 ms - fl/gfx/gamma_lut.h
  │ │   ├─    3.9 ms - fl/chipsets/encoders/pixel_iterator_adapters.h
  │ │   ├─    0.8 ms - fl/chipsets/encoders/sk9822.h
  │ │   └─    0.7 ms - fl/chipsets/encoders/hd108.h
  │ └─    2.4 ms - rgbw.h
  │   └─    2.2 ms - fl/gfx/rgbw.h
  └─   18.2 ms - pixeltypes.h
    ├─   15.1 ms - lib8tion.h
    │ ├─    7.6 ms - fl/math/math8.h
    │ │ ├─    3.9 ms - fl/math/intmap.h
    │ │ │ └─    3.1 ms - platforms/intmap.h
    │ │ ├─    2.0 ms - fl/math/scale8.h
    │ │ │ └─    1.9 ms - platforms/scale8.h
    │ │ │   └─    0.8 ms - platforms/shared/scale8.h
    │ │ └─    1.6 ms - platforms/math8.h
    │ │   └─    1.2 ms - platforms/shared/math8.h
    │ └─    1.6 ms - fl/math/beat.h
    │   └─    0.8 ms - fl/math/trig8.h
    │     └─    0.8 ms - platforms/trig8.h
    │       └─    0.7 ms - platforms/shared/trig8.h
    └─    2.8 ms - crgb.hpp
fl/ui.h (105.9ms)
  ├─   66.9 ms - fl/stl/json.h
  │ └─   52.6 ms - fl/stl/json/types.h
  │   └─    6.2 ms - fl/stl/limits.h
  ├─    9.7 ms - fl/ui_impl.h
  │ └─    9.1 ms - platforms/ui_defs.h
  │   ├─    2.0 ms - platforms/shared/ui/json/audio.h
  │   │ └─    0.9 ms - platforms/shared/ui/json/audio_internal.h
  │   ├─    1.4 ms - platforms/shared/ui/json/button.h
  │   │ └─    0.6 ms - platforms/shared/ui/json/ui_internal.h
  │   ├─    0.9 ms - platforms/shared/ui/json/checkbox.h
  │   ├─    0.8 ms - platforms/shared/ui/json/help.h
  │   └─    0.8 ms - platforms/shared/ui/json/number_field.h
  └─    5.7 ms - fl/stl/url.h
chipsets.h (25.2ms)
  ├─   10.4 ms - fl/chipsets/ucs7604.h
  │ └─    7.8 ms - fl/chipsets/encoders/ucs7604.h
  ├─    5.9 ms - fl/chipsets/apa102.h
  ├─    1.5 ms - fl/chipsets/lpd880x.h
  ├─    0.9 ms - fl/chipsets/encoders/ws2816.h
  └─    0.7 ms - fl/chipsets/p9813.h

TOP 20 SLOWEST OPERATIONS
--------------------------------------------------------------------------------
  1.  1091.3 ms - Source: FastLED.h
  2.  1091.3 ms - Total Source: 
  3.   561.1 ms - Total ParseClass: 
  4.   506.0 ms - Source: fl/task/executor.h
  5.   384.9 ms - Source: fl/fastled.h
  6.   281.4 ms - Source: fl/task/scheduler.h
  7.   269.0 ms - Source: fl/stl/singleton.h
  8.   268.4 ms - Source: fl/stl/thread_local.h
  9.   267.2 ms - Source: fl/stl/thread.h
 10.   267.1 ms - Source: platforms/thread.h
 11.   267.1 ms - Source: platforms/stub/thread_stub.h
 12.   267.0 ms - Source: platforms/stub/thread_stub_stl.h
 13.   261.7 ms - Source: thread
 14.   218.5 ms - Source: crgb.h
 15.   217.3 ms - Source: fl/gfx/crgb.h
 16.   213.1 ms - Source: fl/math/ease.h
 17.   211.8 ms - Source: fl/task/promise.h
 18.   211.2 ms - Source: fl/math/fixed_point.h
 19.   190.8 ms - Total InstantiateFunction: 
 20.   165.9 ms - Total InstantiateClass: 

PERFORMANCE FLAGS
--------------------------------------------------------------------------------
⚠️  SLOW HEADERS (>50.0ms):
    - FastLED.h (1091.3ms)
    - fl/task/executor.h (506.0ms)
    - fl/fastled.h (384.9ms)
    - fl/task/scheduler.h (281.4ms)
    - fl/stl/singleton.h (269.0ms)
    - fl/stl/thread_local.h (268.4ms)
    - fl/stl/thread.h (267.2ms)
    - platforms/thread.h (267.1ms)
    - platforms/stub/thread_stub.h (267.1ms)
    - platforms/stub/thread_stub_stl.h (267.0ms)

⚠️  Template instantiation time is high (37.1% of total)
✓  Lexing time is acceptable (<10% of total)

RECOMMENDATIONS
--------------------------------------------------------------------------------
1. Consider optimizing FastLED.h (1091.3ms)
2. Consider optimizing fl/task/executor.h (506.0ms)
3. Consider optimizing fl/fastled.h (384.9ms)

================================================================================

zackees added a commit that referenced this pull request Apr 18, 2026
…oor (#2253)

NoiseFloorTracker.update() initializes its floor to the first observed
level on the first sample. For a steady loud signal, that makes
isAboveFloor() stuck at false — floor catches up to level, so
level > floor+hysteresisMargin never holds. Reactive (PR #2309) and
Processor wired setSilent() to !isAboveFloor(), which caused a LOUD
1 kHz tone to be flagged as silent, then decayed dominantFrequency
and magnitude to zero via SilenceEnvelope.

Fix: gate silence on an absolute RMS threshold (10.0, matching
NoiseFloorTrackerConfig::minFloor default). The noise-floor estimate
is still tracked for detector internals but is no longer the silence
primitive. "No signal present" is an absolute-level concept.

Tests:
- audio_reactive.cpp: extend phase 2 silence to 3s (~15 taus) so
  pure-exponential decay reaches the < 0.01 assertion instead of
  depending on the now-fixed buggy silent-during-loud shortcut.
- tempo_analyzer.hpp: extend phase 2 silence to 8s (tau=2s → 4 taus)
  so exp(-4) ≈ 0.018 decay is well under 0.05 even when
  liveConfidence comes in high; prior 5s was flaky at the threshold.

Also fix pre-existing KBI003 lint in ci/util/fbuild_compiledb.py
that was blocking this branch's lint gate.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Apr 18, 2026
…oor (#2253) (#2322)

NoiseFloorTracker.update() initializes its floor to the first observed
level on the first sample. For a steady loud signal, that makes
isAboveFloor() stuck at false — floor catches up to level, so
level > floor+hysteresisMargin never holds. Reactive (PR #2309) and
Processor wired setSilent() to !isAboveFloor(), which caused a LOUD
1 kHz tone to be flagged as silent, then decayed dominantFrequency
and magnitude to zero via SilenceEnvelope.

Fix: gate silence on an absolute RMS threshold (10.0, matching
NoiseFloorTrackerConfig::minFloor default). The noise-floor estimate
is still tracked for detector internals but is no longer the silence
primitive. "No signal present" is an absolute-level concept.

Tests:
- audio_reactive.cpp: extend phase 2 silence to 3s (~15 taus) so
  pure-exponential decay reaches the < 0.01 assertion instead of
  depending on the now-fixed buggy silent-during-loud shortcut.
- tempo_analyzer.hpp: extend phase 2 silence to 8s (tau=2s → 4 taus)
  so exp(-4) ≈ 0.018 decay is well under 0.05 even when
  liveConfidence comes in high; prior 5s was flaky at the threshold.

Also fix pre-existing KBI003 lint in ci/util/fbuild_compiledb.py
that was blocking this branch's lint gate.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/audio-silence-gate-reactive-spectral branch May 30, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant