From 8ddf99789e0ff54bc51b5b517c42f40a6d40d2a4 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 4 Feb 2026 14:42:02 +0100 Subject: docs: Update project state with event-based tracker and WAV dump Updated PROJECT_CONTEXT.md and TODO.md to reflect recent milestones: PROJECT_CONTEXT.md changes: - Updated Audio section: stereo format, variable tempo, event-based triggering - Added milestone for "Event-Based Tracker for Tempo Scaling" - Added milestone for "WAV Dump Backend for Debugging" - Updated Audio Engine architecture section with new details - Updated test counts (17/17 passing) TODO.md changes: - Added "Event-Based Tracker for Tempo Scaling" to Recently Completed * Refactored from pattern compositing to individual event triggering * Dynamic beat calculation enables notes to respect tempo scaling * ActivePattern tracking with start_music_time and next_event_idx * All 17 tests pass, WAV dump confirms correct behavior - Added "WAV Dump Backend for Debugging" to Recently Completed * WavDumpBackend for offline rendering to .wav files * Fixed critical stereo format bug (mono/stereo mismatch) * Added regression test with stereo format assertion * Command-line option: --dump_wav output.wav Current State: - All tests passing: 17/17 (100%) - Audio system: Stereo, variable tempo, event-based tracking - Documentation: Up to date with latest architecture Ready for handoff to Gemini. Co-Authored-By: Claude Sonnet 4.5 --- TODO.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'TODO.md') diff --git a/TODO.md b/TODO.md index 7ef10ee..632442b 100644 --- a/TODO.md +++ b/TODO.md @@ -3,6 +3,26 @@ This file tracks prioritized tasks with detailed attack plans. ## Recently Completed (February 4, 2026) +- [x] **Event-Based Tracker for Tempo Scaling**: + - [x] **Problem Identified**: Notes within patterns didn't accelerate with tempo changes. Pattern events were pre-composited into single spectrograms at fixed positions. + - [x] **Refactored Architecture**: Changed from pattern compositing to individual event triggering. Each TrackerEvent now triggers as separate voice. + - [x] **Dynamic Beat Calculation**: `elapsed_beats = (music_time - start_time) / beat_duration` allows notes to respect tempo scaling. + - [x] **ActivePattern Tracking**: Added structure to track pattern_id, start_music_time, and next_event_idx for each active pattern instance. + - [x] **Removed Compositing Logic**: Deleted paste_spectrogram approach that baked events at fixed frame offsets. + - [x] **Full Tempo Scaling**: At 2.0x tempo, both pattern triggering AND note spacing play 2x faster. At 0.5x tempo, both play 2x slower. + - [x] **Testing**: Updated test_tracker.cc to verify individual event triggers at specific beat times. All 17 tests pass. + - [x] **WAV Verification**: Confirmed with WAV dump showing 61.24s music time in 60s physical time during tempo transitions. + +- [x] **WAV Dump Backend for Debugging**: + - [x] **Implementation**: Created WavDumpBackend implementing AudioBackend interface to render audio offline to .wav files. + - [x] **Command-Line Option**: Added `--dump_wav output.wav` flag to enable offline rendering instead of live playback. + - [x] **Stereo Bug Fix**: Fixed critical mono/stereo mismatch. Synth outputs STEREO (interleaved L/R) but initial implementation wrote MONO. + - [x] **Correct Allocation**: Changed to allocate `frames * 2` samples and write stereo format (num_channels = 2). + - [x] **Format Matching**: WAV header now correctly specifies 16-bit PCM, stereo, 32kHz (matches live audio exactly). + - [x] **Regression Test**: Added test_wav_dump.cc with critical assertion `assert(header.num_channels == 2)` to prevent future mismatches. + - [x] **Tempo Simulation**: WAV dump backend simulates tempo scaling matching main.cc logic for accurate offline rendering. + - [x] **All Tests Pass**: 17/17 tests pass including WAV format verification. + - [x] **Variable Tempo System**: - [x] **Music Time Abstraction**: Implemented unified music time in `main.cc` that advances at `tempo_scale` rate, decoupling from physical time. - [x] **Tempo Control**: Added `g_tempo_scale` (default 1.0) allowing future dynamic tempo changes without pitch shifting. -- cgit v1.2.3