0
0

Hi folks,

I’m new here, trying to get started with fmod in Unity.

I’m looking for the best way to implement a master volume setting in my game, and I see in the C++ documentation that there is a function System::getMasterChannelGroup that looks useful. I don’t see it available in the C# Unity integration though.

What would be the best way to control the master volume in Unity?

Cheers,
/Mikael

  • You must to post comments
0
0

Seems the ERRCHECK method is private now?

This code works for me, but doesn’t do error checking.

[code:1u1rancx]
public float volume = 1.0f;
FMOD.Studio.MixerStrip masterBus;

void Start()
{
    FMOD.GUID guid;
    FMOD.Studio.System system = FMOD_StudioSystem.instance.System;
    system.lookupID("bus:/", out guid);
    system.getMixerStrip(guid, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out masterBus);
}

void Update()
{
    masterBus.setFaderLevel(volume);
}

[/code:1u1rancx]

  • You must to post comments
0
0

Hi peter,

That solution looks good but is it still current?
I trying to use it with some minor modifications for the newer version and keep getting null pointers regarding the masterbus.

In Start
[code:rkv1vo9r]FMOD.GUID guid;
FMOD.Studio.System system = FMOD_StudioSystem.instance.System;
FMOD_StudioSystem.ERRCHECK(system.lookupID("/", out guid));
FMOD_StudioSystem.ERRCHECK(system.getMixerStrip(guid, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out masterBus));[/code:rkv1vo9r]

On Update:
[code:rkv1vo9r]FMOD_StudioSystem.ERRCHECK(masterBus.setFaderLevel(volume));[/code:rkv1vo9r]

I’m also fairly new to FMOD, and after a quick search I have been unable to find the API referenced in your comment.
Is volume a limited between 0 and 1?

  • You must to post comments
0
0

I was struggling with this for a while as well. I figured it had to be something to do with the path because when I debug logged the returned GUID it was all zeroes. Turns out, when you export GUIDs from FMOD Studio the text file output contains all the paths that you need. From this, all bus paths must begin "bus:/". Similar to the event instance paths beginning with "event:/".

If you do:
[code:353v06o6]FMOD_StudioSystem.ERRCHECK(system.lookupID("bus:/", out guid));[/code:353v06o6]

That should work =)

  • You must to post comments
0
0

Hi Mikael,

You can retrieve the master bus using the API and control it’s volume directly. The path of the master bus is "/" so the code would look something like this:

[code:3gu46xgq]using UnityEngine;
using System.Collections;

public class MasterVolume : MonoBehaviour
{
public float volume = 1.0f;

FMOD.Studio.MixerStrip masterBus;

void Start() 
{
    FMOD.GUID guid;
    FMOD.Studio.System system = FMOD_StudioSystem.instance.System;
    ERRCHECK( system.lookupBusID("/", out guid) );
    ERRCHECK( system.getMixerStrip(guid, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out masterBus) );
}

void Update()
{
    ERRCHECK( masterBus.setFaderLevel(volume) );
}

void ERRCHECK(FMOD.RESULT result)
{
    FMOD_StudioSystem.ERRCHECK(result);
}

}
[/code:3gu46xgq]

  • You must to post comments
0
0

Thanks a lot!

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.