SFX and Music levels control in the game's sound options menu

Hello,

I’m working in a game that has diferentiated volume controls for sfx and music. This was already working before, when the game wasn’t using fmod.

Now that all the sound is managed from fmod I wanted to “link” the existing code concerning audio options to fmod’s buses or vcas.

I have been looking at tutorials, the manual and this Q&A site and the best I found was:

http://www.fmod.org/documentation/#content/generated/FMOD_Studio_VCA_SetFaderLevel.html

Wich I think is the line of code I need, but I don’t understand how to use it. We are using C#. How do I specify which vca I want to change? Do I have to use the name or an ID? Do I have to declare something beforehand?

Just looking at code doing something similar would be enough for me to try to adapt it to my game but I don’t find anything.

Anyone with experience using vcas or busses with Unity?

Thanks.

I answer myself with my findings in case this is helpful for anyone.

With the help of the programmer, we managed to make it work.
The code we used is:

public void SetMusicMixerVolume(float value) {
float dbVolume = (value * 100f) - 80f;
RuntimeManager.GetVCA(“vca:/music”).setFaderLevel(value);
}
public void SetSFXMixerVolume(float value) {
float dbVolume = (value * 100f) - 80f;
RuntimeManager.GetVCA(“vca:/fx”).setFaderLevel(value);
}

Hope it helps.

1 Like

Just for correctness, linear to db looks like

float db = linear > 0 ? 20.0f * Mathf.Log10(linear * Mathf.Sqrt(2.0f)) : -80.0f;

Thanks!

Thank you very much Damm this was killing me almost a full hour of research before I found this.