diff options
| author | skal <pascal.massimino@gmail.com> | 2026-03-05 09:48:02 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-03-05 09:48:02 +0100 |
| commit | f48562060413634b13706c3ffd01180da98b6049 (patch) | |
| tree | 01db16cdf63705feca07b5c9a1594fcf8daf5fda /tools/spectool.cc | |
| parent | 124666b9c55df0c2f4ccf77053651050c400248c (diff) | |
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.
Diffstat (limited to 'tools/spectool.cc')
| -rw-r--r-- | tools/spectool.cc | 6 |
1 files changed, 5 insertions, 1 deletions
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)) { |
