summaryrefslogtreecommitdiff
path: root/assets/final/shaders/solarize.wgsl
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-07 21:34:00 +0100
committerskal <pascal.massimino@gmail.com>2026-02-07 21:34:00 +0100
commit727177329f833f76683b53570f3268c39b463e86 (patch)
treea4e531c06e719ba8cf49df5436ecc5bdca955364 /assets/final/shaders/solarize.wgsl
parentf9c5e84f01d0d7d1c981db4a0594dee9986429c4 (diff)
fix(audio): Calculate sample offsets from render position, not playback position
This fixes irregular timing in miniaudio playback while WAV dump was correct. ROOT CAUSE: Sample offsets were calculated relative to the ring buffer READ position (audio_get_playback_time), but should be calculated relative to the WRITE position (where we're currently rendering). The write position is ~400ms ahead of the read position (the lookahead buffer). ISSUE TIMELINE: 1. tracker_update() gets playback_time (read pos, e.g., 0.450s) 2. Calculates offset for event at 0.500s: (0.500 - 0.450) * 32000 = 1600 samples 3. BUT: We're actually writing at 0.850s (write pos = read pos + 400ms buffer) 4. Event triggers at 0.850s + 1600 samples = 0.900s instead of 0.500s! 5. Result: Event is 400ms late! The timing error was compounded by the fact that the playback position advances continuously between tracker_update() calls (60fps), making the calculated offsets stale by the time rendering happens. SOLUTION: 1. Added total_written_ tracking to AudioRingBuffer 2. Added audio_get_render_time() to get write position 3. Updated tracker.cc to use render_time instead of playback_time for offsets CHANGES: - ring_buffer.h: Add get_total_written() method, total_written_ member - ring_buffer.cc: Initialize and track total_written_ in write() - audio.h: Add audio_get_render_time() function - audio.cc: Implement audio_get_render_time() using get_total_written() - tracker.cc: Use current_render_time for sample offset calculation RESULT: Sample offsets now calculated relative to where we're currently rendering, not where audio is currently playing. Events trigger at exact times in both WAV dump (offline) and miniaudio (realtime) playback. VERIFICATION: 1. WAV dump: Already working (confirmed by user) 2. Miniaudio: Should now match WAV dump timing exactly Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'assets/final/shaders/solarize.wgsl')
0 files changed, 0 insertions, 0 deletions