Change Platform based on Channel mode

I’d like to selectively include Resonance audio only when the user is playing with headphones or choose the default spatializer when playing with a surround system.
As far as I know, it’s possible to do two different “Platforms” for the same Platform for making a distinction between Stereo and Multichannel and also which Plugins to include. So I’ve made two Desktop Platforms, named Headphones and Surround.
1.Does the output sub directory can stay the same or also has to be different, as I don’t want to include the audio files twice. Or do I have to tick, don’t build assets fo this platform and use a separate directory? 2. And how is the Platform chosen by Unity? I assume this couldn’t be changed while the bank is already loaded?

I’m unable to find any infos and maybe I’m thinking wrong? I might be confusing banks and platforms as they are quite tied together.

Thanks in advance!

Hi,

There may be an alternate solution that doesn’t require building multiple sets of banks. If you have a look at the FMOD Studio Example Project, which is included with the FMOD Studio download here: "C:\Users\XXX\Documents\FMOD Studio\examples\Examples.fspro". There is an event called event:/Music/Radio Station which uses a parameter to control which spatializer it uses:


If this is not a viable solution:

As you are creating two different variations of the banks with the same names, you will have to use two different sub-directories with assets included.

This will depend on how you are loading the banks in the FMOD Settings:
image
and whether FMOD is loading the banks for you:
image
These will control how banks are loaded and whether FMOD does it for you or if you want full control.

Thank you a lot for your illustrative answer!

It makes sense, to solve it via a parameter, but I’ve hoped that there was an alternative where you could switch plugins based on whether the system is detecting stereo or surround.
But it’s probably best to make an option ingame and let the user switch and go with the parameter route.

And yes, I’m loading the banks automatically. The other option would in that case be to load them oneself, make two banks and let the user set again the channel format and then reload the corresponding banks manually, if I understood correctly.

I’ve now also found again under 8.2 in the documentation, what I had originally in mind when asking the question. It was unclear for me that plugin “include only…” is resulting in different assets, which makes sense now.

Thanks again a lot!

1 Like

Hi,

Apologies, you can detect when the output device using a core system callback: FMOD Engine | Core API reference - System

private FMOD.SYSTEM_CALLBACK callback;
// Start is called before the first frame update
void Start()
{
    callback = new FMOD.SYSTEM_CALLBACK(SystemCallback);

    FMOD.RESULT result = FMODUnity.RuntimeManager.CoreSystem.setCallback(callback, FMOD.SYSTEM_CALLBACK_TYPE.DEVICELISTCHANGED);

    if (result == FMOD.RESULT.OK)
    {
        Debug.Log("Assigned callaback");
    }
    else
    {
		Debug.Log("Failed to assign callaback");
    }
}

[AOT.MonoPInvokeCallback(typeof(FMOD.SYSTEM_CALLBACK))]
private static FMOD.RESULT SystemCallback(IntPtr system, FMOD.SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata)
{
    if (type == FMOD.SYSTEM_CALLBACK_TYPE.DEVICELISTCHANGED)
    {
        Debug.Log("Output device changed");
        return FMOD.RESULT.OK;
    }
    return FMOD.RESULT.OK;
}

Yes, the banks would have to be reloaded and all the events would have to be started again. This is where changing the banks during runtime may be an issue. Whereas using the example you won’t have to worry about loading and unloading or having multiple banks.

Hope this helps!

Thanks a lot, that’s really helpful!

1 Like