Environmental Audio in Allegro5?
Mark Oates

Hey what's up. Has anyone done some legwork on, or come across something related to real-time game audio processing using Allegro 5? Allegro appears to have an impressive audio chain so it looks very possible.

I'm looking specifically at being able to filter sound effect audio through a "reverb" filter, in a performant way, similar to Super Mario World when you enter an underground cave. There are other applications for audio filtering that I'd like to try out, too, but this is where I hope to start.

Dizzy Egg

I would recommend irrklang, it’s a really straightforward sound engine that allows you to use a bunch of different effects without much fuss, here’s a link with example of effects:

https://www.ambiera.com/irrklang/tutorial-sound-effects.html

Edgar Reynaldo

You can also use OpenAL, it's a 3D audio library by KittyCat.

Todd Cope

You can use al_set_mixer_postprocess_callback() to process audio before it is sent to the audio device.

To do SNES-style reverb you could just keep a buffer of samples to be mixed in at a lower volume at an offset from when they were initially played. This is an oversimplification, of course, but it should point you in the right direction if you want to use Allegro for this.

Mark Oates
Todd Cope said:

You can use al_set_mixer_postprocess_callback() to process audio before it is sent to the audio device.
To do SNES-style reverb you could just keep a buffer of samples to be mixed in at a lower volume at an offset from when they were initially played. This is an oversimplification, of course, but it should point you in the right direction if you want to use Allegro for this.

Thank you Todd, that was really good advice. I had initially abandoned that direction but thanks to your comment I continued and was able to make substantial progress.

Apparently, the actual math behind reverb is more than just one or two simple algorithms. There's art behind it, and one can craft many different kinds of reverb - it's somewhat analogous to writing an artistic shader. Working on this lead me down a path of circular buffers, sample sizes, buffer lengths, channel configurations, all-pass filters, all these exciting things. Apparently there's an audio programming society of people who specialize in audio programming and do that exclusively as a programming career, who knew! It's a very deep domain.

I found a nice youtube video "Let's write a reverb", which was a good talk on the subject.

At this point, I've managed to write a solid circular buffer, a mixer, and a delay filter (with delay_sec and decay) that will be included it in my codebase. With this much, I've moved the ball forward and now have a good foundation for an actual reverb in the next steps. Hopefully some exciting news coming up. :)

Thread #618733. Printed from Allegro.cc