From 0a214db53ea7c35d5b00fa9f827481fe00aebda4 Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 2 Mar 2022 05:56:18 +1000 Subject: [PATCH] Clarify scheduling of sound start times. --- miniaudio.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/miniaudio.h b/miniaudio.h index f17496e7..16e6c030 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -400,7 +400,13 @@ the be started and/or stopped at a specific time. This can be done with the foll The start/stop time needs to be specified based on the absolute timer which is controlled by the engine. The current global time time in PCM frames can be retrieved with `ma_engine_get_time()`. The engine's global time can be changed with `ma_engine_set_time()` for synchronization purposes if -required. +required. Note that scheduling a start time still requires an explicit call to `ma_sound_start()` +before anything will play: + + ```c + ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time(&engine) + (ma_engine_get_sample_rate(&engine) * 2); + ma_sound_start(&sound); + ``` The third parameter of `ma_sound_init_from_file()` is a set of flags that control how the sound be loaded and a few options on which features should be enabled for that sound. By default, the sound @@ -1393,6 +1399,9 @@ can be useful to schedule a sound to start or stop: ma_sound_set_stop_time_in_pcm_frames(&sound, ma_engine_get_time(&engine) + (ma_engine_get_sample_rate(&engine) * 2)); ``` +Note that scheduling a start time still requires an explicit call to `ma_sound_start()` before +anything will play. + The time is specified in global time which is controlled by the engine. You can get the engine's current time with `ma_engine_get_time()`. The engine's global time is incremented automatically as audio data is read, but it can be reset with `ma_engine_set_time()` in case it needs to be