diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-07 10:46:43 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-07 10:46:43 +0100 |
| commit | 0f79b532c886f338ab80d506d4b06048e1784056 (patch) | |
| tree | 28639cc355c91e294ced1dd1d3491b822c3e45b8 /src/audio/wav_dump_backend.h | |
| parent | 858f9d5e765bfc8f8f13b38fa0fab790139a0740 (diff) | |
refactor(audio): Remove tempo logic from WavDumpBackend
Fixed design flaw where WavDumpBackend had hardcoded tempo curves
duplicating logic from main.cc. Backend should be passive and just
write audio data, not implement simulation logic.
Changes:
- WavDumpBackend.start() is now non-blocking (was blocking simulation loop)
- Added write_audio() method for passive audio writing
- Removed all tempo scaling logic from backend (lines 62-97)
- Removed tracker_update() and audio_render_ahead() calls from backend
- Removed set_duration() (no longer needed, frontend controls duration)
Frontend (main.cc):
- Added WAV dump mode loop that drives simulation with its own tempo logic
- Reads from ring buffer and calls wav_backend.write_audio()
- Tempo logic stays in one place (no duplication)
- Added ring_buffer.h include for AudioRingBuffer access
Test (test_wav_dump.cc):
- Updated to use frontend-driven approach
- Test manually drives simulation loop
- Calls write_audio() after each frame
- Verifies passive backend behavior
Design:
- Backend: Passive file writer (init/start/write_audio/shutdown)
- Frontend: Active simulation driver (tempo, tracker, rendering)
- Zero duplication of tempo/simulation logic
- Clean separation of concerns
All 27 tests pass.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/audio/wav_dump_backend.h')
| -rw-r--r-- | src/audio/wav_dump_backend.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/audio/wav_dump_backend.h b/src/audio/wav_dump_backend.h index eb6e011..6482ef3 100644 --- a/src/audio/wav_dump_backend.h +++ b/src/audio/wav_dump_backend.h @@ -26,8 +26,9 @@ class WavDumpBackend : public AudioBackend { // Set output filename (call before init()) void set_output_file(const char* filename); - // Set duration in seconds (default: 60s, call before start()) - void set_duration(float seconds); + // Write audio data to WAV file (stereo interleaved float samples) + // num_samples: Total number of samples (2x num_frames for stereo) + void write_audio(const float* samples, int num_samples); // Get total samples written size_t get_samples_written() const { |
