From 3a3eca975f15d1e025d6c46c6de253d2abaa7170 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 15 Feb 2026 16:41:08 +0100 Subject: fix(audio): WAV dump drift improvements, acceptable state WAV dump changes: - Bypass ring buffer, render directly with synth_render() - Frame accumulator eliminates truncation errors - Skip pre-fill and fix seek for WAV dump mode - Result: No glitches, -150ms drift at 64b (acceptable) Timeline editor: - Fix waveform tooltip position calculation - Increase beat bar visibility (0.5 opacity) Cleanup: - Remove all drift debugging code from audio.cc and tracker.cc Status: Acceptable for now, further investigation needed. Co-Authored-By: Claude Sonnet 4.5 --- src/audio/audio.cc | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'src/audio/audio.cc') diff --git a/src/audio/audio.cc b/src/audio/audio.cc index f5bc4ab..ba76a28 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -108,10 +108,6 @@ void audio_render_ahead(float music_time, float dt, float target_fill) { if (chunk_frames <= 0) return; - static int64_t g_total_render_calls = 0; - static int64_t g_total_frames_rendered = 0; - const int64_t frames_before = g_ring_buffer.get_total_written() / RING_BUFFER_CHANNELS; - // Keep rendering small chunks until buffer is full enough while (true) { // First, try to flush any pending samples from previous partial writes @@ -228,19 +224,6 @@ void audio_render_ahead(float music_time, float dt, float target_fill) { } } } - - // DEBUG: Track actual frames rendered vs expected - const int64_t frames_after = g_ring_buffer.get_total_written() / RING_BUFFER_CHANNELS; - const int64_t actual_rendered = frames_after - frames_before; - g_total_render_calls++; - g_total_frames_rendered += actual_rendered; - - if (g_total_render_calls % 600 == 0) { // Every 10 seconds at 60fps - const float expected_frames = g_total_render_calls * (float)(chunk_frames); - const float drift_ms = (expected_frames - g_total_frames_rendered) / RING_BUFFER_SAMPLE_RATE * 1000.0f; - printf("[RENDER_DRIFT] calls=%lld expect=%.1f actual=%lld drift=%.2fms\n", - g_total_render_calls, expected_frames, g_total_frames_rendered, drift_ms); - } } float audio_get_playback_time() { -- cgit v1.2.3