Multiple AudioMixer instanced from Addressables

Here is the problem,

We defined a unique AudioMixer in our project with multiple groups.

We are also using Addressables.

The AudioMixer is instanced multiple time (up to 3, probably more) (when looking in the Audio Profiler).

The first hint I got was from SetFloat broken for new exposed Audio Mixer parameters , we use to have that problem too.

By putting the AudioMixer in an Addressable Group we reduced the “instance” count to 2, but it seems to continue to provoke sound bugs.

Any know issues or workaround ?

This bug occurs at least on :
Unity 2018.4.15f1, 2018.4.17f1 with Addressables version is 1.6.2

To give more information, we have multiple scenes, when the first scene is loaded, only one audiomixer is loaded, but after loading a second scene the second audiomixer is loaded.
An interesting test I made was to bind the AudioMixer in object in each scenes. The one on the first scene looks normal
5528125--567976--correcly_bound_audio_mixer.png
but the one in the second one does not seem to be right.
5528125--567973--incorectly_bound_audio_mixer.png

AudioMixerBug.zip is a repro case for the bug here is the step :

  1. Open FirstScene.unity
  2. Build Addressable : Build>New Build>Default Build Script
  3. Open Profiler and select Audio, Detailed, Channels and groups, Reset play count on play
  4. Press start button, look that the audiomixer’s channels are loaded once
  5. Press any button on the green screen, it moves you to SecondScene, look that the audiomixer’s channels are loaded twice

5528125–568018–AudioMixerBug.zip|attachment (419 KB)

1 Like

We were interested in this bug so we have tried your reproduction project on 2019.3.3 and we don’t have this problem with this version.

I also tested it on 2019.3.3f1 and at first I thought I didn’t have the bug, BUT the strange binding problem persist :frowning: but that is true that in that repro, I don’t have the double mixer visually anymore.

Thank you anyway

@ Any advice ?

Maybe Try @unity_bill

+1

+1

+1

+1

I experience the same problem (Unity 2019.4.30f, Win10), I’ve got two AudioMixers instantiated. In the first scene there is only one mixer, on the second I get two. Interestingly, all audio is routed through the mixer that can not be edited via “Edit in Play Mode” button. Additionally most content (including AudioSources) reside in AssetBundles in my case. I wonder how the AudioMixer is instantiated internally? To me it looks like one mixer is loaded as a dependency from the asset bundle but the other one is somehow loaded by default (maybe with the AudioListener?).
Any idea how to work around this problem?

+1, I’m having this issue on build. In Editor, it works correctly, I have only one Mixer instance. But in Build, there is two and it causes some problems like, if I change a parameter in mixer, the other copy mixer is not affected by the change of that. (We are using IL2CPP for build.)

1 Like

I also ran into this problem. It looks like we need some kind of GLOBAL mixer for the block, which will always and will not depend on Addressable. Otherwise, this whole system with mixers becomes absolutely useless in conjunction with Addressable.
The saddest thing is that I spent a huge amount of time searching for the bug myself, at a time when it was a known problem. Such problems should be explicitly documented, otherwise you are just mocking your developers. This is absolutely not a clear violation of the logic of the workflow.

1 Like

This was a pain to fix and after spending some time here’s the easiest “fix”.

Note, we didn’t want to make our scenes addressables as this would have changed the workflow for our entire project.
Our project uses Addressables for levels and enemies, but the scenes, ui, etc are not addressables.

  1. Create a singleton to store your audio mixer.

  2. In the singleton, you can either load the AudioMixer as an addressable or choose to use the scene reference.

  3. Choose one of the following:

If you choose to use Addressables (i.e. AssetReference), then you should add a component to every scene AudioSource to set the mixer group at runtime.

If you choose to use the scene reference audio mixer, then you should add a component to every Addressable prefab that has an audio source to set the mixer group at runtime.

  public class MixerSingleton : MonoBehaviour
    {
        public static MixerSingleton Instance;

        [SerializeField]
        private AssetReference _mixerAddressable;

        [SerializeField] private AudioMixer _sceneMixer;

        public AudioMixer Mixer { get; private set; }

        public void Awake()
        {
            if (Instance == null)
            {
                Instance = this;
            } else if (Instance != this)
            {
                Destroy(this);
                return;
            }
            DontDestroyOnLoad(this);
            
            // Choose one 
            SetupSceneMixer();
            // SetupAddressablesMixer();
        }

        private void SetupAddressablesMixer()
        {
            Addressables.LoadAssetAsync<AudioMixer>(_mixerLoader).Completed += OnCompleted;
        }

        private void SetupSceneMixer()
        {
            Mixer = _sceneMixer;
        }

        private void OnCompleted(AsyncOperationHandle<AudioMixer> obj)
        {
            Mixer = obj.Result;
        }
    }

We went with using the scene reference to the AudioMixer as there was many more AudioSource in scenes to set the group for then there were Addressables. So the idea is to update the addressable AudioSource mixer group to the group from the scene reference at runtime.