Skip to content

fix(audio): initialize SoundLevelMeter smoothing on the first block #4518

Closed

Description

@zackees

Context

In SoundLevelMeter::processBlock, the global dBFS floor starts at +infinity. With a positive smoothing alpha, the first nonempty block blends its finite dBFS with infinity, leaving the floor infinite and getSPL() at negative infinity. With alpha 1, 0 * infinity can produce NaN.

Repro: construct SoundLevelMeter(33.0, 0.5), process one sample of value 1000, then call getSPL(); expected a finite value, actual -infinity.

Proposal

Initialize the smoothed floor from the first valid measurement before blending later blocks.

Acceptance criteria

  • Add a focused test that is RED on current master for a first nonempty block with smoothing enabled, then GREEN after the fix.
  • getDBFS() and getSPL() are finite after the first and subsequent valid blocks for representative positive alpha values, including 1.

Decisions

  • Scope is first-measurement initialization, not a change to the meter's smoothing model; the failure is deterministic without hardware.
  • Priority: medium; the default smoothing path can invalidate SPL output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions