How to enable or disable effects on audio mixer at runtime?

Hi there,

I am trying to enable or disable low pass effect on my audio mixer at runtime (enable it when my player is shell shocked to make all sounds deeper to simulate temporary deaf)

I tried googling but it seems nobody is even trying to do so? Like I am the only one having this issue

So, how am I supposed to do this? I thought enabling or disabling effects at runtime would be the easiest solution, seems it is not …

3 Likes

We have exactly the same problem, Ist sometimes quite funny like unity can’t implement so obvious things like disabling sound effect by code. I still cant find any solution for that.

1 Like

Thanks for bumping up the thread, still no luck on my end either…

I think the way to do this is to is with AudioMixer snapshots. this video will explain it better than I can.

https://www.youtube.com/watch?v=2nYyws0qJOM

Thank you

This is not a fix for a problem.

1 Like

+1 for being able to bypass fx channels in code

1 Like

You can use mixer.SetFloat to change the cutoff frequency of your lowpass filter (after exposing that variable). When you want the effect on, set the value low, but when you want it off, change it to 22000. Remember to import Unity.Audio into your script!

Can you confirm no audio processing is happening when you do that though? Without the ability to disable/bypass an audio FX through code, each solution to turn it “off” is custom and doesn’t stop the processing from happening.

It is also my hunch that there is still processing behind the scenes. We can only assume that if they were thoughtful enough to turn it off when you crank to the max would have thought to put a programmable bypass in as well.

You can’t even bypass it on one snapshot and have it enabled on another. It’s insane something so obvious for performance would be omitted from a game engine. Unity’s audio tooling is complete trash.

2 Likes

I can’t simply turn on/off audio effects without having them constantly processing it in the background? If that’s true, then that is absolutely INSANE.

2 Likes

I’m not 100% sure because I didn’t test it on a player, but AudioMixerGroup are actually AudioMixerGroupController, an internal class that could be accessed through reflection and which has the parameters bypassEffects, solo, mute and even a list of effects.

It reminds me of the AnimatorController, which has a similar class related to it that can’t be used on a build, but this seems it would work.

I doubt it’s that bad… I agree there is much to do but come on :stuck_out_tongue: have some faith! We love sound at least as much as you do. I’ll have a look at this because it’s a valid concern, but I’m hopeful. A quick scan in the code base reveals the existence of a few bypass-like variables, but it’s always complicated to jump the hoops between Unity and FMOD. To be continued…

2 Likes

I’m delighted to have some communication on this, thanks for taking a look.

After some digging, I can confirm that bypassed effects are not being processed when turned off. When the “wetness” of an effect is detected as 0, it automatically set the bypass flag, effectively NOT calling the processing function of the plugin.

2 Likes