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. --- src/audio/ola.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/audio/ola.cc') diff --git a/src/audio/ola.cc b/src/audio/ola.cc index 738df85..fd5098e 100644 --- a/src/audio/ola.cc +++ b/src/audio/ola.cc @@ -21,14 +21,18 @@ void ola_encode(const float* pcm, int n_samples, float* spec, int num_frames) { } } +void ola_decode_frame(const float* spec_frame, float* overlap, float* out_hop) { + float tmp[DCT_SIZE]; + idct_512(spec_frame, tmp); + for (int j = 0; j < OLA_HOP_SIZE; ++j) + out_hop[j] = tmp[j] + overlap[j]; + for (int j = 0; j < OLA_OVERLAP; ++j) + overlap[j] = tmp[OLA_HOP_SIZE + j]; +} + void ola_decode(const float* spec, int num_frames, float* pcm) { float overlap[OLA_OVERLAP] = {}; - float tmp[DCT_SIZE]; for (int f = 0; f < num_frames; ++f) { - idct_512(spec + f * DCT_SIZE, tmp); - for (int j = 0; j < OLA_HOP_SIZE; ++j) - pcm[f * OLA_HOP_SIZE + j] = tmp[j] + overlap[j]; - for (int j = 0; j < OLA_OVERLAP; ++j) - overlap[j] = tmp[OLA_HOP_SIZE + j]; + ola_decode_frame(spec + f * DCT_SIZE, overlap, pcm + f * OLA_HOP_SIZE); } } -- cgit v1.2.3