summaryrefslogtreecommitdiff
path: root/doc/ASSET_SYSTEM.md
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-07 21:43:30 +0100
committerskal <pascal.massimino@gmail.com>2026-02-07 21:43:30 +0100
commit9d91a1b6f5fa26605fb8567e61603d07d2f6fd9e (patch)
treef580a255e1672075b8a3c7f8ea055e4c4b8c10ee /doc/ASSET_SYSTEM.md
parent727177329f833f76683b53570f3268c39b463e86 (diff)
fix(audio): Remove sample offsets - incompatible with tempo scaling
This fixes the irregular timing caused by mixing music time and physical time. ROOT CAUSE (THE REAL BUG): Sample offset calculation was mixing two incompatible time domains: 1. event_trigger_time: in MUSIC TIME (tempo-scaled, can be 2x faster) 2. current_render_time: in PHYSICAL TIME (1:1 with real time, not scaled) When tempo != 1.0, these diverge dramatically: Example at 2.0x tempo: - Music time: 10.0s (advanced 2x faster) - Physical render time: 5.0s (real time elapsed) - Calculated offset: (10.0 - 5.0) * 32000 = 160000 samples = 5 SECONDS! - Result: Event triggers 5 seconds late This caused irregular timing because: - At tempo 1.0x: offsets were roughly correct (domains aligned) - At tempo != 1.0x: offsets were wildly wrong (domains diverged) - Result: Random jitter as tempo changed WHY WAV DUMP WORKED: WAV dump doesn't use tempo scaling (g_tempo_scale = 1.0), so music_time ≈ physical_time and the domains stayed aligned by accident. THE SOLUTION: Remove sample offsets entirely. Trigger events immediately when music_time passes their trigger time. Accept ~16ms quantization (one frame at 60fps). TRADE-OFFS: - Before: Attempted sample-accurate timing (but broken with tempo scaling) - After: ~16ms quantization (acceptable for rhythmic events) - Benefit: Consistent timing across all tempo values - Benefit: Same behavior in WAV dump and miniaudio playback CHANGES: - tracker.cc: Remove offset calculation, always pass offset=0 - Simplify event triggering logic - Add comment explaining why offsets don't work with tempo scaling Previous commits (9cae6f1, 7271773) attempted to fix this with render_time tracking, but missed the fundamental issue: you can't calculate sample offsets when event times and render times are in different time domains. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'doc/ASSET_SYSTEM.md')
0 files changed, 0 insertions, 0 deletions