|
Set audio buffer chunk size? |
Tumlee
Member #15,061
April 2013
|
When testing out a game I'm making with Allegro 5, I couldn't help but notice that the timing on a rapidly-playing (about 5 times per second) sound seemed "off". What I mean by this is that the sound wasn't playing at a constant rhythm, but rather erratically changing the timing between each sound. Back when I was working with SDL, there was an option you could set when creating initializing the audio that was essentially the size of a "chunk" of audio. This is a completely different thing than the frequency and its normal value was usually around 2048. Making this value a high number would reduce the instance of pops and crackles that might happen on slower computers, but it caused horrid timing issues like the one I described above. Likewise, lowering the value made crackling more likely to happen, but it almost completely fixed any timing issues I was having. Is there a way to adjusting this sort of setting in Allegro 5? I read through the API but the only thing that looked promising were the 'fragment_count' and 'samples' arguments to al_create_audio_stream(). I don't think this is what I'm looking for, though, because I'm not sure you can even play sound effects to an audio stream. |
Peter Wang
Member #23
April 2000
|
Not in a systematic way, but that would be nice to have. The DirectSound driver's buffer size can be set through the allegro5.cfg file, under key directsound.buffer_size.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
al_create_audio_stream accepts a frag_samples parameter - this is essentially your buffer size, in number of samples per fragment (fragment_count) per audio stream. A5 online manual said: The choice of fragment_count, frag_samples and freq directly influences the audio delay. The delay in seconds can be expressed as: delay = fragment_count * frag_samples / freq This is only the delay due to Allegro's streaming, there may be additional delay caused by sound drivers and/or hardware.
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Tumlee
Member #15,061
April 2013
|
Edgar Reynaldo said: al_create_audio_stream accepts a frag_samples parameter - this is essentially your buffer size, in number of samples per fragment (fragment_count) per audio stream Is it possible to pump calls to al_play_sample() through an audio stream, though? Otherwise, it really doesn't help me. Peter Wang said: Not in a systematic way, but that would be nice to have. If it would be nice to have, should I throw out a feature request for it? Or is there some underlying reason why it can't be done directly through Allegro? I guess I'll just take your suggestion, though. It probably won't help any Linux users but it sounds like it will at least solve that problem under Windows. |
Peter Wang
Member #23
April 2000
|
It's not hard, just work. Also unsure how to expose it through the API but maybe that can come later.
|
Thomas Fjellstrom
Member #476
June 2000
|
Tumlee said: I'm not sure you can even play sound effects to an audio stream. You can play anything you want through a stream. At the lower levels there is no real conceptual difference, other than allegro does the streaming for you when using sample instances. -- |
Tumlee
Member #15,061
April 2013
|
Thomas Fjellstrom said: You can play anything you want through a stream. At the lower levels there is no real conceptual difference, other than allegro does the streaming for you when using sample instances. From what I understand from the API guide, you can load and play a sound as an audio stream, but that's not the same thing as playing multiple sample instances through an already-running audio stream, and I don't think that's what they're for. I'm probably not going to solve any lag issues unless I can change the buffer size of the actual mixer. |
|