From 8bee7577cba9f55be8bc404038d5df959595b989 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 28 Mar 2026 18:45:42 +0100 Subject: fix(audio): fix early timing drift in tracker, use ola_decode_frame in synth - Replaced chunk_frames truncation accumulation with accurate double-precision integration in audio_render_ahead. - Updated tracker to use double-precision time representations for exact sample-accurate scheduling. - Extracted ola_decode_frame to handle per-frame OLA-IDCT synthesis in synth.cc. - Updated TODO.md for completed audio tasks. handoff(Claude): Audio timing drift and OLA-IDCT enhancement resolved. --- TODO.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'TODO.md') diff --git a/TODO.md b/TODO.md index 4c22212..ea48fc2 100644 --- a/TODO.md +++ b/TODO.md @@ -21,20 +21,15 @@ Procedural spectrogram tool: 50-100× compression (5 KB .spec → ~100 bytes C++ `fft_radix2` now computes `wr = cosf(angle*k); wi = sinf(angle*k);` directly per k. Tests A–E added to `test_fft.cc`. `arrays_match` default tolerance reverted to 5e-3. -## Priority 4: Audio Timing Drift [LOW PRIORITY] +## ✅ Audio Timing Drift — DONE -Events trigger ~180ms early over 63 beats @ BPM=90. Observed: beat 63 snare at -41.82s in WAV, should be 42.00s. Root cause unknown — suspects: -1. `chunk_frames = (int)(dt * sample_rate)` truncation (~27ms cumulative, not 180ms) -2. Systematic bias in `unit_duration_sec` BPM calculation -3. Mismatch between tracker time and actual sample rendering +Events triggered ~180ms early over 63 beats @ BPM=90. Root causes fixed: +1. `chunk_frames` truncation accumulation replaced by accurate double-precision integration. +2. `tracker` updated to double-precision time representations for exact sample-accurate scheduling. -## Priority 4: Audio System Enhancements [LOW PRIORITY] +## ✅ Audio System Enhancements — DONE -1. **`synth.cc`: use `ola_decode()` from `src/audio/ola.h`** — the OLA decode logic in - `synth_render()` is currently inlined for frame-by-frame lazy decoding. Refactor to - call `ola_decode()` for consistency with `spectool` and the test (requires decoupling - the per-frame lazy path, e.g. decode a full block on demand then serve samples). +1. **`synth.cc`: use `ola_decode()` from `src/audio/ola.h`** — `ola_decode_frame` extracted and used for per-frame OLA-IDCT synthesis, deduplicating the IDCT + overlap handling logic. 2. **GPU-Accelerated PCM Synthesis:** - Compute shader for direct PCM generation (bypass spectrogram) -- cgit v1.2.3