Engine: Improve support for fading in and out of sounds.

Fading is now set using these APIs:

  * ma_engine_sound_set_fade_in()
  * ma_engine_sound_set_fade_out()

When a sound is stopped, either by naturally reaching the end, or
explicitly with ma_engine_sound_stop(), the fade out will be applied.
Fading will also be applied around loop transitions.

Note that when a sound is stopped implicitly by it reaching the end,
fading out will not work when the length of the sound is not know (that
is, when ma_data_source_get_length_in_pcm_frames() returns 0).
This commit is contained in:
David Reid
2020-08-14 13:25:47 +10:00
parent b61fc570a2
commit 6d1a1ccd05
2 changed files with 173 additions and 51 deletions
+5 -4
View File
@@ -39,12 +39,13 @@ int main(int argc, char** argv)
ma_engine_sound_set_pitch(&engine, &sound, 1.0f);
ma_engine_sound_set_pan(&engine, &sound, 0.0f);
ma_engine_sound_set_looping(&engine, &sound, MA_TRUE);
ma_engine_sound_start(&engine, &sound, 4000);
ma_engine_sound_seek_to_pcm_frame(&engine, &sound, 1000000);
//ma_engine_sound_seek_to_pcm_frame(&engine, &sound, 6000000);
ma_engine_sound_set_fade_in(&engine, &sound, 2000);
ma_engine_sound_set_fade_out(&engine, &sound, 2000);
ma_engine_sound_start(&engine, &sound);
ma_sleep(5000);
ma_engine_sound_stop(&engine, &sound, 4000);
//ma_engine_sound_stop(&engine, &sound);
#endif
#if 1