Search Unity

Audio "Popping" sound when adjusting mixer volume

Discussion in 'Audio & Video' started by dgoyette, Nov 16, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    In my game, when I completely stop audio sources, I often hear a popping sound. To avoid that, I'm trying to gradually lower the total game volume using the Audio mixer. However, even when using the Audio mixer to lower the volume, I'm still hearing popping sounds. This occurs the first frame that I change the audio mixer volume.

    I'm using code like this to adjust the mixer volume while a sound is playing:

    Code (CSharp):
    1. Mixer.TransitionToSnapshots(new AudioMixerSnapshot[] { snapshotA, snapshotB }, new float[] { 1,0 }, 0);
    I've tested this out in a very simple scene, where there is just an audio source playing. I've set up two Audio Mixer snapshots, each simply has a different volume. While playing, I press a key to execute the code above to switch snapshots. This produces a very noticeable "pop" with every snapshot change. My expectation is that volume can be lowered without hearing popping sounds. It definitely seems worse depending on which sound I use. (Some seem more prone to popping than others.)

    Is there any possibility of avoiding this? Or is audio popping a fact of life when changing mixer volume? I've tried all combinations of import settings on the audio file itself, and they all result in popping.
     
  2. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    139
    Try changing the starting volume of the default mixer group (which I'm guessing is at 0db?) to a slightly lower value (such as -0.05db).

    I've found that Audio Mixer Snapshots can sometimes pop when they move from the default 0db but setting the value to something other than 0 fixes it.



    If you still get popping after this, try using a longer time to reach value, (if you're not already) e.g. 0.1f, to add a small fade.
     
    dgoyette likes this.
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    aihodge and JLF like this.
  4. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    You can - just reply to the email
     
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Ah, thanks. I missed then in the email I got. Thanks for pointing that out.
     
  6. orestesgas

    orestesgas

    Joined:
    Jul 29, 2017
    Posts:
    3
    Thanks guys! I was getting crazy with this! One year after and the bug is still there... Thank you so much!
     
  7. orestesgas

    orestesgas

    Joined:
    Jul 29, 2017
    Posts:
    3
    Oh! Now I see that the answer is provided by John Leonard French... You are the best! If you need a kidney or something, let me know haha! Thanks again.
     
    JLF likes this.
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,789
    I see this bug is closed. Can you ask them to reopen?

    QA clearly misunderstood. Please reopen that bug. Doing a transition from 0 to -80db in half a second, sometimes results in a pop. Doing -0.05 to -80, in the same amount of time, does not result in a pop. It's not about sudden changes, it's about starting from 0db exactly. It's a bug.
     
  9. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Sure. I replied to the issue asking them to reopen and consider what you've said here.
     
    AcidArrow likes this.
  10. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,789
    Awesome, thank you @dgoyette

    I'm hoping bug fix will be backported though, if not to 2018 LTS at least in time for 2019 LTS.
     
  12. GrayedFox

    GrayedFox

    Joined:
    Jan 28, 2014
    Posts:
    70
    I get the audio popping any time I change the mixer of an AudioSource, even if the volume is the same (I change mixers because one mixer has effects while the other does not). I guess I could also just add effects to the one mixer and bypass them, disabling the bypass when needed, but that's a workaround I would like to avoid.

    Does anyone have experience dealing with popping when changing the mixer of an audio source? The volume for each is 1.0db (and the volume for any mixer I use set to 0 is actually -0.05db, as recommended)
     
  13. GrayedFox

    GrayedFox

    Joined:
    Jan 28, 2014
    Posts:
    70
    To clarify: I'm not changing the volume of the mixer, but actually changing the mixing source/output stream of the AudioSource. The reason is because while the game is paused, the music/background sound is altered to reflect the paused state (pausing is a core gameplay mechanic of the game and more of a skill).
     
  14. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I have never changed the mixer associated with an audio source at runtime, so I don't have any experience dealing with the popping issue you're experiencing. However, one thing you could try is instead of changing the mixer, have you tried using snapshots for the different effects, instead of separate mixers?

    I use AudioMixer.TransitionToSnapshots, for example, to kind of crossfade between two snapshots on an Audio Mixer as the player experiences loud explosion noises, and things get muffled for a while:

    Normal sound effects:
    upload_2021-2-2_12-13-30.png

    After an explosion:
    upload_2021-2-2_12-14-4.png

    And since you get to set relative strengths of the different snapshots, you can animate the change from one snapshot to another, instead of an abrupt change that might occur if you're changing the mixer in a single frame.

    Anyway, just an approach you might consider.
     
  15. Quoellfrisch

    Quoellfrisch

    Joined:
    Feb 3, 2021
    Posts:
    8
    If you look at the MainMixer in the Project-View.
    Disable the "Auto Mixer Suspend" that should get rid of the popping sounds.