diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-04 14:27:56 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-04 14:27:56 +0100 |
| commit | 02336d13cbb5c3109583cd258696e88afe7cf9bb (patch) | |
| tree | 8af529214cca3c23fb4d02d809b16e821c53f75c /src/generated/assets.h | |
| parent | e6cc5f40a0eadba904cbb56e3429c1c16bb46fad (diff) | |
test(audio): Add regression test for WAV dump stereo format
Added comprehensive test to prevent mono/stereo mismatch regressions.
What This Test Prevents:
The recent bug where WAV dump wrote mono instead of stereo caused severe
audio distortion. This regression test ensures the format always matches
the live audio output configuration.
Test Coverage (test_wav_dump.cc):
1. **test_wav_format_matches_live_audio()**:
- Renders 60 seconds of audio to WAV file
- Reads and parses WAV header
- Verifies critical format fields:
✓ num_channels = 2 (MUST be stereo!)
✓ sample_rate = 32000 Hz
✓ bits_per_sample = 16
✓ audio_format = 1 (PCM)
✓ byte_rate calculation correct
✓ block_align calculation correct
- Verifies audio data is non-zero (not silent)
- Cleans up test file after
2. **test_wav_stereo_buffer_size()**:
- Verifies buffer size calculations for stereo
- frames_per_update = ~533 frames
- samples_per_update = frames * 2 (stereo)
- Prevents buffer overflow issues
Key Assertions:
```cpp
// CRITICAL: This assertion prevented the regression
assert(header.num_channels == 2); // MUST be stereo!
```
If anyone accidentally changes the WAV dump to mono or breaks the
stereo format, this test will catch it immediately.
Integration:
- Added to CMakeLists.txt after test_mock_backend
- Requires: audio, util, procedural, tracker music data
- Test count: 16 → 17 tests
- All tests passing (100%)
Output:
```
Test: WAV format matches live audio output...
✓ WAV format verified: stereo, 32kHz, 16-bit PCM
✓ Matches live audio output configuration
Test: WAV buffer handles stereo correctly...
✓ Buffer size calculations correct for stereo
✅ All WAV Dump tests PASSED
```
Future Protection:
This test will immediately catch:
- Accidental mono conversion
- Sample rate changes
- Bit depth changes
- Buffer size calculation errors
- Format mismatches with live audio
handoff(Claude): Regression test complete, stereo format protected
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/generated/assets.h')
0 files changed, 0 insertions, 0 deletions
