From 8c5e41724fdfc3be24e95f48ae4b2be616404074 Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 26 Mar 2026 10:09:34 +0100 Subject: fix(audio): P1-P3 fixes from audio code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P1 — correctness bugs: - tracker.cc: move delete[] loop before pool reset so guard condition is valid - audio_engine: replace tracker_reset() with tracker_init() in reset()/seek() so synth IDs are re-registered after synth_init() clears spectrogram slots - spectrogram_resource_manager: set spec.version in load_procedural() (was UB) P2 — minor bugs: - synth.cc: move pan clamp unconditionally before debug-only block - gen.cc: remove dead `freq` variable in generate_note_spectrogram() - tracker.cc: remove duplicate g_sample_synth_cache clear loop P3 — cleanup: - Replace hardcoded 32000.0f with RING_BUFFER_SAMPLE_RATE (5 sites) - audio.cc: extract clip_samples() helper, remove duplicated clip loops - audio_engine: inline update_silent(), remove no-op prewarm_for_time_range() - Remove stale comments: stdio.h include, NEW: labels, CACHING block, NOTE: - Move TODO(timing) drift notes from source to TODO.md handoff(Gemini): audio review implemented, 36/36 tests passing --- TODO.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'TODO.md') diff --git a/TODO.md b/TODO.md index c5b71e9..eb530ec 100644 --- a/TODO.md +++ b/TODO.md @@ -21,6 +21,14 @@ 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] + +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 + ## Priority 4: Audio System Enhancements [LOW PRIORITY] 1. **`synth.cc`: use `ola_decode()` from `src/audio/ola.h`** — the OLA decode logic in -- cgit v1.2.3