From 5c7feffd3749ce4b355d0db6334cf39ca94d8d82 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 15 Feb 2026 23:56:43 +0100 Subject: perf(audio): smooth playback time and RMS-based peak at 60Hz Interpolates audio playback time between callbacks using CLOCK_MONOTONIC for smooth 60Hz updates instead of coarse 8-10Hz steps. Replaces artificial peak decay with true RMS calculation over 50ms window. Ring buffer computes RMS directly on internal buffer without copies for efficiency. All backends updated with get_callback_state() interface for time interpolation. Tests passing (34/34). Co-Authored-By: Claude Sonnet 4.5 --- src/audio/audio_backend.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/audio/audio_backend.h') diff --git a/src/audio/audio_backend.h b/src/audio/audio_backend.h index d9c4690..980ee6e 100644 --- a/src/audio/audio_backend.h +++ b/src/audio/audio_backend.h @@ -3,6 +3,7 @@ // Enables testing without hardware by abstracting audio output. #pragma once +#include // AudioBackend interface for audio output abstraction // Production uses MiniaudioBackend, tests use MockAudioBackend @@ -25,6 +26,11 @@ class AudioBackend { // Note: This should measure peak at actual playback time, not pre-buffer time virtual float get_realtime_peak() = 0; + // Get callback state for smooth time interpolation + // out_time: Timestamp of last audio callback (seconds) + // out_samples: Total samples read at last callback + virtual void get_callback_state(double* out_time, int64_t* out_samples) = 0; + #if !defined(STRIP_ALL) // Hook called when a voice is triggered (test-only) // timestamp: Time in seconds when voice was triggered -- cgit v1.2.3