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/backend/mock_audio_backend.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/audio/backend/mock_audio_backend.cc') diff --git a/src/audio/backend/mock_audio_backend.cc b/src/audio/backend/mock_audio_backend.cc index 068d8a3..60be429 100644 --- a/src/audio/backend/mock_audio_backend.cc +++ b/src/audio/backend/mock_audio_backend.cc @@ -30,6 +30,12 @@ float MockAudioBackend::get_realtime_peak() { return 0.5f; } +void MockAudioBackend::get_callback_state(double* out_time, + int64_t* out_samples) { + *out_time = (double)current_time_sec_; + *out_samples = (int64_t)(current_time_sec_ * kSampleRate * 2); +} + void MockAudioBackend::on_voice_triggered(float timestamp, int spectrogram_id, float volume, float pan) { // Record the event with the timestamp provided by synth -- cgit v1.2.3