diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-07 10:53:28 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-07 10:53:28 +0100 |
| commit | 41876cd44b29113fbe72749665f1dd4fd473f27a (patch) | |
| tree | c288ca6e36682cee018c599a2ebb2fe1bb736bce /src/audio/tracker.h | |
| parent | 0f79b532c886f338ab80d506d4b06048e1784056 (diff) | |
fix(audio): Remove clipping from WavDumpBackend, add diagnostics
Fixed design flaw where WavDumpBackend was clamping samples to [-1.0, 1.0]
before writing to file. This prevented detection of audio problems.
Changes:
- Removed sample clamping (lines 57-60 in old code)
- WAV dump now records audio "as is" (matches MiniaudioBackend behavior)
- Added clipped_samples_ counter to track diagnostic metric
- Added get_clipped_samples() method for programmatic access
- Report clipping statistics in shutdown():
- "✓ No clipping detected" when clean
- "WARNING: N samples clipped (X% of total)" when clipping occurs
- Suggests reducing volume to fix
Why this matters:
- MiniaudioBackend does NOT clip samples (passes directly to miniaudio)
- WavDumpBackend should match this behavior
- Clipping in WAV files helps identify audio distortion problems
- Developers can compare WAV output to expected values
- Diagnostic metric helps tune audio levels
Testing:
- Added test_clipping_detection() test case
- Verifies clipping counter works correctly (200 clipped / 1000 samples)
- Existing tests show "✓ No clipping detected" for normal audio
- All 27 tests pass
Example output:
WAV file written: test.wav (2.02 seconds, 128986 samples)
✓ No clipping detected
WAV file written: loud.wav (10.5 seconds, 336000 samples)
WARNING: 4521 samples clipped (1.35% of total)
This indicates audio distortion - consider reducing volume
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/audio/tracker.h')
0 files changed, 0 insertions, 0 deletions
