Change output type in the game

Hi,

We have a multiplatform FMOD build for our game made in Unity.

We want to implement a setting for every platform for users to be able to select a preferred audio device to adjust in-game audio settings for this.

We have PC and Xbox, so I’ve created the following platform builds as an example:
PC Headphones
PC Speakers
Xbox Headphones
Xbox Speakers

I already know that we can adjust settings and plugins that will affect only specific builds that we select within FMOD Studio.

And we want to add this setting for user to be able to select in settings menu. How do we do that? I’ve searched forums and only managed to find some sort of automatic change (related to mobile devices), when user changes output (by connecting headphones, for example).

I presume one way to work around this is to create snapshots that we save and store every time when player launches the game, but maybe there are some specific ways related to platforms?

Thanks in advance!

Apologies for the delayed response over the new years break.

Changing the output device/driver itself is fairly straightforward - you can use System::setDriver to set the device FMOD is outputting to. System::getNumDrivers and System::getDriverInfo can be used in conjunction to enumerate available devices. With the FMOD for Unity plugin, the relevant call might look something like this:

FMOD.System coresystem;
FMODUnity.RuntimeManager.StudioSystem.getCoreSystem(out coresystem);
coresystem.setDriver(3);

As for changing platform builds with different speaker formats (i.e. headphones/2.0, 5.1, 7.1), that’s a little more involved. The easiest way to do it, assuming the source assets are the same across all platform builds, is to enable the “Build metadata and assets to separate banks” setting in FMOD Studio’s build preferences. Then, at runtime, you can keep all asset banks loaded, while unloading the currently loaded metadata banks and loading the new ones with the target speaker format. The simplest way to handle this is to use RuntimeManager.LoadBank() and RuntimeManage.UnloadBank(), and RuntimeManage.HasBankLoaded() can be used to query the loading state of a given bank.

Note, however, that unloading all metadata banks includes the master bank, and as a result all existing events will be stopped and release, so keeping track of the events that need to persist through the swap (ambience, music, etc.) is a good idea.

You can read more about how to handle changing audio configurations in the relevant section of the Studio docs: 16.16 Setting Up Different Audio Configurations for your Game

Just following up on this - was the info in my previous reply enough to inform you on how to go about swapping output devices and/or builds? If not, did you run into any issues?