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 Should I use Audio Mixers to let the player change the voulme for SFX and Music seperately?

Discussion in 'Audio & Video' started by Steven-1, Feb 6, 2023.

  1. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    451
    I haven't used Audio Mixers before, but as far as I can tell, it's the only (practical) way to allow the players to change the volume of the SFX and Music separately, by creating audio mixers for these 2, and assigning the correct to each audiosource.

    But I'm wondering if this has any impact on performance, as these mixers can do a lot more than just change the audio volume, but I'm not interested in any of that.

    So does anyone have any experience with this?


    The only other way to do this, as far as I'm aware, is to make all of the audiosources have a script attached to them that multiplies the audiosource's volume with a sfx-volume-variable. (that can then be changed by the player)

    Or does anyone know any other way?
     
  2. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    137
    There's no major performance disadvantage to using Audio Mixers for managing audio levels, particularly user-accessible controls. In fact, this is exactly what they're for.

    While there are effects that you can add to mixers that have a big impact on performance, generally just running audio through the mixers and controlling the levels won't cause you any problems.

    For a simple use-case, I'd make one Audio Mixer and run SFX and Music through two Audio Mixer Groups.

    For a more complex setup, use multiple mixers that manage groups of sounds that in turn feed into other mixers. This might be useful for managing overall audio balance and allows mixers to auto-suspend if they're not being used (again, only really relevant if you're using effects).

    In any case, probably keep user controls separate from controls that you use while making your game to balance audio. Which might mean a couple of mixers or groups.

    But, put simply, don't worry about the performance impact of using mixers, they're generally very lightweight on their own.

    Hope that helps.
     
    Steven-1 likes this.
  3. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    451
    Good to hear! Thanks for the help, I'll do it like that then!
     
  4. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    290
    The most obvious super power of the mixer is the "Duck Volume" effect (also known as side-chain compression). That allows you to make sure that your most important sound-bus keeps the front scene when you have a lot going on, while preserving the ears of the player.

    For a project, we had a game where the player could listen to a radio and I used the mixer's distortion and high-pass effects to ease-in or out of the different stations. I don't see how that could have been done otherwise.

    When you put your game on pause you could also want to lower, without totally killing, your game's sound. Mixer snapshots are a great way to shift between different soundscapes.