- Online Community Forums » Programming Questions » How to do use an audio stream

This thread is locked; no one can reply to it. rss feed Print
How to do use an audio stream
roger levy
Member #2,513
July 2002

I need help understanding the new audio stream system so I can implement a synth in my game. In Allegro 4 I remember you gave the audio stream a callback and it would just work in the background. Now things seem to be based on the event system. I imagine this could become an issue when executing intensive things like the rendering phase. Are you meant to answer the fragment events in a separate thread?

Member #358
May 2000

I don't think A4 had a callback:

You would just busy wait calling the stream function over and over - this was the time of DOS before there could be multiple processes competing for CPU (and before CPUs had a feature which allowed them to idle) :P

I don't think rendering should be an issue. Waiting for vsync can take up to 1/60th of a second (16.6 ms), that should be small enough to not notice audio delay. Actual rendering in Allegro games should be a factor 10 to 100 faster than that so I'd say the rendering itself is never an issue.

Still, I don't see anything that would speak against using a separate thread either - then you can fill audio data even while the main thread waits on vsync in al_flip_display().

"Either help out or stop whining" - Evert

roger levy
Member #2,513
July 2002

I could have sworn it was a callback in A4. Maybe I was using another library for sound. I discovered the post-process callback; I get a nice stable stream free from pops or clicks so this will work. Not sure if this means the thread is done, but I'm glad it's there.

Go to: