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 Unity Audio Mixer max volume

Discussion in 'Audio & Video' started by Adybo123, Mar 28, 2021.

  1. Adybo123

    Adybo123

    Joined:
    Jan 31, 2017
    Posts:
    2
    Hi there!

    I'm currently in the process of making Music and SFX volume sliders for my game's settings.
    In my game, sometimes quite a few of the same sound effect can go off at once. They add up and get quite loud. That's fine - I like it being louder when there is more going on and I understand that this is correct behaviour, audio-wise. However, what I'd like is some way to *cap* the max volume of an AudioMixerGroup.

    For example, at the moment if you put SFX on 1%, and then tonnes go off - it can pretty much deafen you by shooting to max volume even though the audio mixer is attenuated to 1% of its normal volume (with the correct Log10 calculation on the slider value).

    Is there a way I can absolutely cap the audio mixer, saying SFX should *never* go above x% volume, even if they're adding up?
     
  2. janm_unity3d

    janm_unity3d

    Unity Technologies

    Joined:
    Jun 12, 2012
    Posts:
    36
    Hi Adybo, that is unavoidable when you’re adding lots of instances of sounds as you may get into situations where all samples are lined up such that all the peaks overlap and therefore result in a level higher than 100%. In practice it doesn’t happen that often, because samples usually don’t align and therefore have a lot of destructive interference, but it sounds like that’s what happens in your case, i.e. you play two sounds in one frame and they are overlapping exactly. You can reduce this effect a little if you slightly randomize the pitch to play it just a few percent slower or faster. This generally also makes the sound more pleasant to listen to when played repetitively.

    To actually keep the level under control I’d recommend playing all the explosions into one audio mixer group and have either a Compressor or Normalize effect on it to keep the volume in a range. A perhaps lesser known trick is that you can also use the Ducking Volume effect for this if you set the Sidechain Mix parameter all the way to 0. Another effective method is to make room for the explosion sounds by using the Ducking Volume effect to automatically attenuate the other sounds (or the master mix) whenever the level of explosion sounds goes up. This allows you to have the explosion sounds at a lower volume and still have them perceived as being louder than the other sounds in the mix that is being ducked. See
    for more info. You could even put a Distortion effect to add more crunch to the sound. Aside from performing the level reduction the clipping will add some harmonics to the sound that may make the explosions sound punchier.
     
    mikaelK likes this.