diff options
Diffstat (limited to 'PROJECT_CONTEXT.md')
| -rw-r--r-- | PROJECT_CONTEXT.md | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/PROJECT_CONTEXT.md b/PROJECT_CONTEXT.md index e5adfb6..8f71ebf 100644 --- a/PROJECT_CONTEXT.md +++ b/PROJECT_CONTEXT.md @@ -32,6 +32,19 @@ Style: ### Recently Completed +#### Milestone: Audio Peak Measurement & Test Coverage (February 7, 2026) ✅ +- **Real-Time Audio Peak Fix**: Resolved critical audio-visual synchronization bug where visual effects triggered ~400ms before audio was heard. Root cause: peak measurement occurred at ring buffer write time (synth_render) instead of playback time (audio callback). Solution: Added `get_realtime_peak()` to AudioBackend interface, implemented real-time peak tracking in MiniaudioBackend audio_callback using exponential averaging (instant attack, 0.7 decay rate for 1-second fade). Updated main.cc and test_demo.cc to use `audio_get_realtime_peak()` API. Result: Perfect audio-visual synchronization, visual effects trigger precisely when audio is heard. + +- **Peak Decay Optimization**: Fixed "test_demo just flashing" issue caused by slow decay rate. Old: 0.95 decay = 5.76 second fade (screen stayed white constantly). New: 0.7 decay = 1.15 second fade (proper flash with smooth decay). Mathematical verification: At 128ms audio callbacks, 0.7^9 ≈ 0.1 after ~1 second. Result: Responsive visual effects with proper attack/decay curves. + +- **SilentBackend Test Infrastructure**: Created test-only audio backend for comprehensive audio.cc testing without hardware. Features: controllable peak for edge cases, tracks frames rendered and voice triggers, pure inspection (no audio output). Created 7 comprehensive tests covering lifecycle, peak control, frame/voice tracking, playback time, buffer management, audio_update safety. Result: Significantly improved audio.cc test coverage (audio_get_playback_time, audio_render_ahead, audio_update all tested). + +- **Backend Reorganization**: Moved all audio backend implementations to src/audio/backend/ subdirectory for cleaner code organization. Moved: miniaudio_backend, mock_audio_backend, wav_dump_backend, jittered_audio_backend, silent_backend (5 backends total). Updated all #include paths in backend files and tests, updated CMakeLists.txt paths. Kept audio_backend.h (interface) in src/audio/. Result: Improved maintainability, zero functionality regressions, all 28 tests pass. + +- **Dead Code Removal**: Removed unused `register_spec_asset()` function from audio.{h,cc}. Function was never called anywhere in codebase. Removed declaration and implementation (lines 43-58). Result: Cleaner codebase, reduced maintenance burden. + +- **Test Coverage Achievement**: All 28 tests passing (100% success rate). New SilentBackend tests provide comprehensive coverage for audio subsystem. No regressions in existing tests. Build clean with no errors or warnings. Files modified: 15 changed, 3 new files, 8 files reorganized. Commit a6a7bf0 ready for push. + #### Milestone: test_demo - Audio/Visual Sync Debug Tool (February 7, 2026) 🎯 - **Standalone Debug Tool**: Created minimal test executable for debugging audio/visual synchronization and variable tempo system without full demo complexity. **Core Features**: Simple drum beat (kick-snare) with crash landmarks at bars 3 and 7, NOTE_A4 (440 Hz) reference tone at start of each bar for testing, screen flash effect synchronized to audio peaks, 16 second duration (8 bars at 120 BPM). **Variable Tempo Mode**: `--tempo` flag enables alternating tempo scaling (even bars: 1.0x → 1.5x acceleration, odd bars: 1.0x → 0.66x deceleration) to test music time vs physical time system. **Peak Logging**: `--log-peaks FILE` exports audio peak data for gnuplot visualization, `--log-peaks-fine` adds millisecond-resolution per-frame logging (~960 samples vs 32 beat-aligned samples). **Command-Line Options**: `--help` shows usage, `--fullscreen` for fullscreen mode, `--resolution WxH` for custom window size. **Error Handling**: Unknown options print error message and help text before exiting with status 1. **File Structure**: `src/test_demo.cc` (main executable, ~220 lines), `assets/test_demo.track` (drum patterns with NOTE_A4), `assets/test_demo.seq` (visual timeline), `test_demo_README.md` (comprehensive documentation). **Peak Log Format**: Beat-aligned mode logs at beat boundaries (32 samples), fine-grained mode logs every frame with beat_number column for correlation. **Build Integration**: CMake target with timeline/music generation, proper dependencies, size optimizations. **Use Cases**: Verify millisecond-precision sync, detect timing jitter, analyze tempo scaling effects, debug flash-to-audio alignment. **Impact**: Provides isolated testing environment for sync verification without demo64k complexity, enables data-driven analysis via exported logs. |
