Convolution-based Reverb in Swap

( Headphones recommended! 🎧 🔊 )

A showcase of different reverb presets enabled and disabled

We recently decided to roll our own audio loop for Swap using cpal and it has been very fun to think and learn about audio code. We switched away from using the higher level rodio library which has served us well up until this point.

The motivation for the switch was to have more control over filters and effects we can dynamically apply to the game’s sound to make environments in Swap feel more immersive.

One step towards more immersion was implementing reverb – specifically I decided to implement a convolution-based reverb.

It turns out that if you use a microphone and record a very short immediate signal, sort of a short clap/snap/click – you get what’s called the impulse response of the place you recorded it. This impulse response encodes qualities of how the place you did the recording echoes/reverbs/affects sounds at that location.

Now, using the impulse response from for example a cave/church/forest (some of which can be freely obtained from the openair database https://www.openair.hosted.york.ac.uk/), we can convolve any sound effect in the game with the impulse response in frequency space and make them feel as if they were played in the location

A bonus is also that we can now have a nice visualization of the audio signal:

Short clip of the audio visualizer in Swap

While most of the code has been “learn-as-we-go” “trial and error”, some useful resources have been:

If you have any questions don’t hesitate to reach out to us at idnointeractive@gmail.com

Follow the development of Swap by joining our discord! discord.idno.se/


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *