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/synth.cc | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/audio/synth.cc') diff --git a/src/audio/synth.cc b/src/audio/synth.cc index 45ced59..9b56069 100644 --- a/src/audio/synth.cc +++ b/src/audio/synth.cc @@ -4,6 +4,7 @@ #include "synth.h" #include "audio/dct.h" +#include "audio/ola.h" #include "util/debug.h" #include #include // For memset @@ -264,20 +265,7 @@ void synth_render(float* output_buffer, int num_frames) { (v.current_spectral_frame * DCT_SIZE); if (v.ola_mode) { - // OLA-IDCT synthesis (v2): no synthesis window. - // Analysis used Hann; at 50% overlap w[n]+w[n+H]=1 so - // rectangular synthesis gives perfect reconstruction. - float tmp[DCT_SIZE]; - idct_512(spectral_frame, tmp); - // Add saved overlap from previous frame - for (int j = 0; j < OLA_OVERLAP; ++j) - tmp[j] += v.overlap_buf[j]; - // Save new tail as overlap for next frame - for (int j = 0; j < OLA_OVERLAP; ++j) - v.overlap_buf[j] = tmp[OLA_HOP_SIZE + j]; - // Output buffer holds first OLA_HOP_SIZE samples - for (int j = 0; j < OLA_HOP_SIZE; ++j) - v.time_domain_buffer[j] = tmp[j]; + ola_decode_frame(spectral_frame, v.overlap_buf, v.time_domain_buffer); } else { // V1: IDCT directly, no windowing idct_512(spectral_frame, v.time_domain_buffer); -- cgit v1.2.3