From f48562060413634b13706c3ffd01180da98b6049 Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 5 Mar 2026 09:48:02 +0100 Subject: fix(spectool): pre-fill audio buffer before audio_start() in play mode Trigger voice and render ahead before starting the audio device to avoid "Audio buffer not pre-filled" warning and silent playback. handoff(Claude): spectool play now produces sound correctly. --- tools/spectool.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tools/spectool.cc') diff --git a/tools/spectool.cc b/tools/spectool.cc index bd17dfc..c3aebb2 100644 --- a/tools/spectool.cc +++ b/tools/spectool.cc @@ -237,7 +237,6 @@ int play_spec(const char* in_path) { PlatformState platform_state = platform_init(false, 100, 100); audio_init(); - audio_start(); Spectrogram spec; spec.spectral_data_a = spec_data.data(); spec.spectral_data_b = @@ -247,6 +246,11 @@ int play_spec(const char* in_path) { int spec_id = synth_register_spectrogram(&spec); synth_trigger_voice(spec_id, 0.7f, 0.0f); + // Pre-fill ring buffer before starting audio device + const float prefill = audio_get_required_prefill_time(); + audio_render_ahead(0.0f, prefill); + + audio_start(); printf("Playing... Press Ctrl+C to exit.\n"); while (synth_get_active_voice_count() > 0 && !platform_should_close(&platform_state)) { -- cgit v1.2.3