summaryrefslogtreecommitdiff
path: root/src/test_demo.cc
AgeCommit message (Collapse)Author
14 hoursfeat(gpu): Systematize post-process bindings and enable vertex shader uniformsskal
- Add PP_BINDING_* macros for standard post-process bind group layout - PP_BINDING_SAMPLER (0): Input texture sampler - PP_BINDING_TEXTURE (1): Input texture from previous pass - PP_BINDING_UNIFORMS (2): Custom uniforms buffer - Change uniforms visibility from Fragment-only to Vertex|Fragment - Enables dynamic geometry in vertex shaders (e.g., peak meter bar) - Replace all hardcoded binding numbers with macros in post_process_helper.cc - Update test_demo.cc to use systematic bindings - Benefits: All post-process effects can now access uniforms in vertex shaders Result: More flexible post-process effects, better code maintainability
15 hoursrefactor: Store const GpuContext& in Effect base classskal
- Changed Effect to store ctx_ reference instead of device_/queue_/format_ - Updated all 19 effect implementations to access ctx_.device/queue/format - Simplified Effect constructor: ctx_(ctx) vs device_(ctx.device), queue_(ctx.queue), format_(ctx.format) - All 28 tests pass, all targets build successfully
15 hoursrefactor: Bundle GPU context into GpuContext structskal
- Created GpuContext struct {device, queue, format} - Updated Effect/PostProcessEffect to take const GpuContext& - Updated all 19 effect implementations - Updated MainSequence.init() and LoadTimeline() signatures - Updated generated timeline files - Updated all test files - Added gpu_get_context() accessor and fixture.ctx() helper Fixes test_mesh.cc compilation error from g_device/g_queue/g_format conflicts. All targets build successfully.
16 hoursfix(audio): Synchronize audio-visual timing with playback timeskal
Problem: test_demo was "flashing a lot" - visual effects triggered ~400ms before audio was heard, causing poor synchronization. Root Causes: 1. Beat calculation used physical time (platform_state.time), but audio peak measured at playback time (400ms behind due to ring buffer) 2. Peak decay too slow (0.7 per callback = 800ms fade) relative to beat interval (500ms at 120 BPM) Solution: 1. Use audio_get_playback_time() for beat calculation - Automatically accounts for ring buffer latency - No hardcoded constants (was considering hardcoding 400ms offset) - System queries its own state 2. Faster decay rate (0.5 vs 0.7) to match beat interval 3. Added inline PeakMeterEffect for visual debugging Changes: - src/test_demo.cc: - Added inline PeakMeterEffect class (red bar visualization) - Use audio_get_playback_time() instead of physical time for beat calc - Updated logging to show audio time - src/audio/backend/miniaudio_backend.cc: - Changed decay rate from 0.7 to 0.5 (500ms fade time) - src/gpu/gpu.{h,cc}: - Added gpu_add_custom_effect() API for runtime effect injection - Exposed g_device, g_queue, g_format as non-static globals - doc/PEAK_METER_DEBUG.md: - Initial analysis of timing issues - doc/AUDIO_TIMING_ARCHITECTURE.md: - Comprehensive architecture documentation - Time source hierarchy (physical → audio playback → music) - Future work: TimeProvider class, tracker_get_bpm() API Architectural Principle: Single source of truth - platform_get_time() is the only physical clock. Everything else derives from it. No hardcoded latency constants. Result: Visual effects now sync perfectly with heard audio.
18 hoursfeat(audio): Add SilentBackend, fix peak measurement, reorganize backendsskal
## Critical Fixes **Peak Measurement Timing:** - Fixed 400ms audio-visual desync by measuring peak at playback time - Added get_realtime_peak() to AudioBackend interface - Implemented real-time measurement in MiniaudioBackend audio callback - Updated main.cc and test_demo.cc to use audio_get_realtime_peak() **Peak Decay Rate:** - Fixed slow decay (0.95 → 0.7 per callback) - Old: 5.76 seconds to fade to 10% (constant flashing in test_demo) - New: 1.15 seconds to fade to 10% (proper visual sync) ## New Features **SilentBackend:** - Test-only backend for testing audio.cc without hardware - Controllable peak for testing edge cases - Tracks frames rendered and voice triggers - Added 7 comprehensive tests covering: - Lifecycle (init/start/shutdown) - Peak control and tracking - Playback time and buffer management - Integration with AudioEngine ## Refactoring **Backend Organization:** - Created src/audio/backend/ directory - Moved all backend implementations to subdirectory - Updated include paths and CMakeLists.txt - Cleaner codebase structure **Code Cleanup:** - Removed unused register_spec_asset() function - Added deprecation note to synth_get_output_peak() ## Testing - All 28 tests passing (100%) - New test: test_silent_backend - Improved audio.cc test coverage significantly ## Documentation - Created PEAK_FIX_SUMMARY.md with technical details - Created TASKS_SUMMARY.md with complete task report Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
23 hoursrefactor: Move platform files to src/platform/ subdirectoryskal
Reorganized platform windowing code into dedicated subdirectory for better organization and consistency with other subsystems (audio/, gpu/, 3d/). Changes: - Created src/platform/ directory - Moved src/platform.{h,cc} → src/platform/platform.{h,cc} - Updated 11 include paths: "platform.h" → "platform/platform.h" - src/main.cc, src/test_demo.cc - src/gpu/gpu.{h,cc} - src/platform/platform.cc (self-include) - 6 test files - Updated CMakeLists.txt PLATFORM_SOURCES variable Verification: ✓ All targets build successfully (demo64k, test_demo, test_platform) ✓ test_platform passes (70% coverage maintained) ✓ demo64k smoke test passed This completes the platform code reorganization side quest. No functional changes, purely organizational.
24 hoursfeat(test_demo): Add validation for command-line optionsskal
Adds error handling for unknown or invalid command-line options: - Unknown options (e.g., --invalid) print error and help, then exit(1) - Missing arguments (e.g., --resolution without WxH) print error and help - Invalid format (e.g., --resolution abc) print error and help Error handling: - Prints specific error message to stderr - Shows full help text for reference - Exits with status code 1 (error) - --help still exits with status code 0 (success) Examples of new behavior: $ test_demo --unknown Error: Unknown option '--unknown' [help text displayed] $ test_demo --resolution Error: --resolution requires an argument (e.g., 1024x768) [help text displayed] $ test_demo --resolution abc Error: Invalid resolution format 'abc' (expected WxH, e.g., 1024x768) [help text displayed] This prevents silent failures and helps users discover correct usage. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
24 hoursfeat(test_demo): Add beat_number column to fine-grained peak logskal
Adds beat_number as 4th column in fine-grained logging mode to enable easy correlation between frame-level data and beat boundaries. File format change: - Before: frame_number clock_time raw_peak - After: frame_number clock_time raw_peak beat_number Benefits: - Correlate frame-level peaks with specific beats - Filter or group data by beat in analysis scripts - Easier comparison between beat-aligned and fine-grained logs - Identify which frames belong to each beat interval Example output: 0 0.000000 0.850000 0 1 0.016667 0.845231 0 ... 30 0.500000 0.720000 1 31 0.516667 0.715234 1 This allows filtering like: awk '$4 == 0' peaks_fine.txt to extract all frames from beat 0. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
24 hoursfeat(test_demo): Add fine-grained peak logging at frame resolutionskal
Adds --log-peaks-fine option to log audio peaks at every frame (~60 Hz) instead of just at beat boundaries, enabling millisecond-resolution synchronization analysis. Features: - --log-peaks-fine flag for per-frame logging - Logs ~960 samples over 16 seconds (vs 32 for beat-aligned) - Header indicates logging mode (beat-aligned vs fine) - Frame number instead of beat number in fine mode - Updated gnuplot command (using column 2 for time) Use cases: - Millisecond-resolution synchronization debugging - Frame-level timing jitter detection - Audio envelope analysis (attack/decay characteristics) - Sub-beat artifact identification Example usage: build/test_demo --log-peaks peaks.txt --log-peaks-fine The fine mode provides approximately 16.67ms resolution (60 Hz) compared to 500ms resolution (beat boundaries at 120 BPM). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
24 hoursfeat(test_demo): Add audio/visual sync debug tool with tempo testingskal
Implements minimal standalone executable for debugging audio/visual synchronization and variable tempo system without full demo complexity. Key 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) alternating acceleration/deceleration - Peak logging (--log-peaks) for gnuplot visualization Command-line options: - --help: Show usage information - --fullscreen: Run in fullscreen mode - --resolution WxH: Set window resolution - --tempo: Enable tempo variation test (1.0x ↔ 1.5x and 1.0x ↔ 0.66x) - --log-peaks FILE: Export audio peaks with beat timing for analysis Files: - src/test_demo.cc: Main executable (~220 lines) - assets/test_demo.track: Drum pattern with NOTE_A4 - assets/test_demo.seq: Visual timeline (FlashEffect) - test_demo_README.md: Comprehensive documentation Build: cmake --build build --target test_demo Usage: build/test_demo [--help] [--tempo] [--log-peaks peaks.txt] Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>