|
music |
duncan perham
Member #15,403
November 2013
|
What is the best way to play music in game. I was using al_load_sample and it all works fine. but this is slow to load as it all has to be loaded into memory at the start (and will eventually use a lot of memory). So I tried al_load_audio_stream, which works, but is poorly documented in how to control it. Also when it gets to the end of the file, it will no longer play it. I have dozens of ogg files, that I need to be able to play at random, however when I play a new one, I need the old one to stop, or fade would be better. The documentation is fine for documenting what each function does, but it dosent give an overview of how to use them all together and what is the correct way to use them. |
Polybios
Member #12,293
October 2010
|
I haven't used the audio addon much myself, but it seems that you can stop an audio stream by passing false to al_set_audio_stream_playing. Edit: |
Elias
Member #358
May 2000
|
al_attach_audio_stream_to_mixer has a link to al_detach_audio_stream in the documentation, so that would be my first guess to stop it again. -- |
Chris Katko
Member #1,881
January 2002
|
Polybios said: I think you can accomplish fading of an individual audio-stream by calling al_set_audio_stream_gain repeatedly with values 1.0 ... 0.0. Isn't that fairly inefficient and subject to logic loop latency? Shouldn't audio playback (since it already depends so much on timing) support something like al_set_audio_stream_gradient(stream, start_volume, end_volume, time_for_envelope)? Ideally, you'd could also use a *_get_gradient_value and *_stop_gradient, so you could change the envelope mid-gradient. But you could fall back to the normal way for those if you had to. -----sig: |
|