UNITY - SetVolume(0) not muting the volume of Event

Using Fmod Studio with Unity and trying to mute an Event but not working.
I’m using setVolume(0) to mute it and debugging with getVolume()

No matter what I set under setVolume, the getVolume() ‘finalVolume’ doesn’t change.
I’m sure I’m doing something wrong, but not what.

This is how I initialize the event in Unity:

//Create event
audioProperties.musicInstance = FMODUnity.RuntimeManager.CreateInstance(eventRef);
FMODUnity.RuntimeManager.AttachInstanceToGameObject(newAudioInstance, parentSource.GetComponent(), parentSource.GetComponent());
audioProperties.musicInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(parentSource.transform));

//Start event and mute it
audioProperties.musicInstance.start();
audioProperties.musicInstance.setVolume(0);

Any help greatly appreciated!

I’m not aware of any reason why that would not work.
Most FMOD functions will return a FMOD.RESULT, which if it fails will give you an indication as to why.

You could also check the fmod log (found in the menu FMOD/Log Viewer).

1 Like

Thanks for the help. I’ve figured it out. I had another function on update doing a setVolume(1) to all audio sources every frame, so it just kept reverting…my bad!

1 Like

I’m having a very similar issue. Except I don’t have any other setVolumes happening, and when I check the volume afterward via getVolume, it did save the setting, except it’s still playing at full volume.

code looks like this

{

FMOD.Studio.Bus bus;

private float busVolume;

private float currentVolume;


void Start()
{
  bus = FMODUnity.RuntimeManager.GetBus("bus:/In Game");
  UpdateVolume();
}

void OnEnable(){
  SettingsMenu.SoundUpdate += UpdateVolume;
}

void OnDisable(){
  SettingsMenu.SoundUpdate -= UpdateVolume;
}


void Update()
{

}


void UpdateVolume(){
  busVolume = PlayerPrefs.GetFloat("BGMVol", 0.5f);
  bus.setVolume(busVolume);
  bus.getVolume(out currentVolume);
  Debug.Log(currentVolume);
}

}

What is the value range you are passing into setVolume? Have you tried checking the results to see if the getVolume and setVolume calls are passing? i.e

void UpdateVolume()
{
    busVolume = PlayerPrefs.GetFloat("BGMVol", 0.5f);
    FMOD.RESULT result = bus.setVolume(busVolume);
    if (result != FMOD.RESULT.OK) Debug.Log("Failed to set volume!");

    result = bus.getVolume(out currentVolume);
    if (result != FMOD.RESULT.OK) Debug.Log("Failed to set volume!");

    Debug.Log(busVolume);
    Debug.Log(currentVolume);
}