Senior Full Stack Server Engineer @ Uncapped Games
21 January 2022
Looking for an easy way to attenuate volume for individual speaker channels in Unity? Unity’s already built a DSP plugin just for you!
Working with lower-level audio in Unity, I struggled finding a simple solution for attenuating low-frequency effects (LFE) channel gain without needing to roll up my sleeves and write a digital signal processing (DSP) effects plugin.
Although I highly recommend anyone interested in learning about audio programming to take a swing at writing their own DSP plugins, it’s a pretty deep rabbit hole for the uninitiated. Thankfully, Unity already has a solution!
Unity provides a staggering 26 DSP plugins in their Native Audio Plugin SDK. However, the documentation ain’t so great - their link to the source currently points to a BitBucket repo that no longer exists (here’s the official GitHub repo) and they don’t go into many details about what the actual plugins do.
Here’s a quick way to get individual speaker channel attenuation working in your project:
Plugins
folder on your computer.AudioPluginDemo.dll
Assets/Plugins
folder and putting it there is the preferable way. Demo - LevelMixer
to your target Mixer. (Check out Unity’s manual on how Mixers work) Othniel Cundangan wrote an excellent article around building the plugins from source from a MacOS perspective. If there’s any interest on how to build from source for Windows using Visual Studio, I would be glad to do a write up - let me know!
Check out your project’s Audio settings in Edit>Project Settings>Audio
- change Default Speaker Mode to Surround 7.1 forcibly show all 8 channels in your mixers.
Take note, your Unity speaker settings will still be downmixed to whatever speaker setup you have registered in your operating system’s audio settings.
Head over to this post’s issue page and put your thoughts in there!