Convolution-based Reverb in Swap

( Headphones recommended! 🎧 🔊 )

A showcase of different reverb presets enabled and disabled

We recently switched away from using the higher level rodio to rolling our own audio loop using cpal and it has been very fun to think and learn about audio code.

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 that goal was implementing reverb – specifically I opted 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

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 *