Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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

Discussion in 'Audio & Video' started by valentin56610, Sep 5, 2022.

  1. valentin56610

    valentin56610

    Joined:
    Jan 22, 2019
    Posts:
    145
    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 ...
     
    benmrx and MrDizzle26 like this.
  2. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    635
    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.
     
    MrDizzle26 likes this.
  3. valentin56610

    valentin56610

    Joined:
    Jan 22, 2019
    Posts:
    145
    Thanks for bumping up the thread, still no luck on my end either...
     
  4. imakegames3

    imakegames3

    Joined:
    May 18, 2022
    Posts:
    1
    I think the way to do this is to is with AudioMixer snapshots. this video will explain it better than I can.
     
  5. valentin56610

    valentin56610

    Joined:
    Jan 22, 2019
    Posts:
    145
    Thank you
     
  6. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    635
    This is not a fix for a problem.
     
  7. MrDizzle26

    MrDizzle26

    Joined:
    Feb 8, 2015
    Posts:
    34
    +1 for being able to bypass fx channels in code
     
  8. Repr99

    Repr99

    Joined:
    Sep 18, 2021
    Posts:
    1
    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!
     
  9. MrDizzle26

    MrDizzle26

    Joined:
    Feb 8, 2015
    Posts:
    34
    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.
     
  10. Zuuunk

    Zuuunk

    Joined:
    Jul 28, 2021
    Posts:
    10
    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.
     
    MrDizzle26 likes this.