Skip to content

fix(audio): preserve INT16_MIN through the signal noise gate #4521

Closed

Description

@zackees

Context

SignalConditioner::applyNoiseGate stores -sample in an i16. Negating -32768 produces 32768 in promoted arithmetic, then narrows back to -32768. The comparison treats a full-scale negative sample as below threshold and zeros it.

Repro: disable DC removal and spike filtering, enable the noise gate, and process one -32768 sample. Expected gate open and -32768 output; actual gate closed and 0 output.

Proposal

Compute absolute magnitude in a wider signed type before threshold comparison.

Acceptance criteria

  • Add a focused RED→GREEN regression for -32768 with other filters disabled.
  • The gate reports open for that sample and preserves it when gain settings otherwise leave it unchanged; neighboring negative/positive amplitudes still follow the threshold.

Decisions

  • Isolate the gate in tests because default spike filtering can mask this defect.
  • Priority: medium; this drops legitimate full-scale PCM peaks.

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