Switching audio output device (esp. for VR)

We’re having problems with fmod using the correct audio output device with VR. A lot of times the headset connects after the start of the application, including in the editor.

fmod seems to not handle this at all, unlike the rest of the Unity audio, which works fine.

Is this as designed? I ask because it’s a big pain for VR, and it’d really be nice if it auto-switched like Unity.

What’s the suggested way to handle switching output devices?

1 Like

After some more testing, I’ve concluded that it doesn’t matter if you start the Oculus app and connect the headset first, before running the Unity editor. It seems like there’s some device hand-off that happens later anyway.

Any suggestions on how to set up an output device switch? Or is this a bug?

By default FMOD will use the system default output device.

The best way to change the output device that FMOD uses is:

Thanks for the info! If the system default output device switches while the app is running, does it update? If so, there seems to be a bug because it doesn’t update when the device switches.

This is currently the way FMOD works, only if the device list has changed (eg. device removed or added) will FMOD update it’s device list.

See this thread for more information:

We are planning to add this behavior in the next major release, as it requires internal behavior changes.

Hello, is there any news regarding this issue? I am also working on a VR proyect and it’s something really important for VR, both Oculus and SteamVR change the windows audio output to the headset when launching the game, and currently if you launch the game directly from Steam before opening SteamVR for example, the windows audio output is changed after the game finished launching so fmod ends up with the last output windows had.

This has been added in version 2.01.00:
https://fmod.com/resources/documentation-api?version=2.1&page=welcome-revision-history.html

  • Core API - Win - FMOD_OUTPUT_DEVICELISTCHANGED_CALLBACK now responds to default device changes.

Hi guys.
I’m in the same position, trying to set Oculus as my main audio device (they demand it to publish with them).
Where should we use the getNumDrivers, getDriverInfo & setDriver?
Right now we are putting some of this code on the “FMOD.RESULT Initialize()” inside of the RuntimeManager but we are experimenting some errors.
Ty

You can do it before init if you are wanting to force it to a particular driver.

System::setDriver

If this function is called after System::init, the current driver will be shutdown and the newly selected driver will be initialized / started.

What errors are you gettings?

Hi, I’m trying to use FMOD while developing a hololens 2 project in unity. I have 2 audios and I want to play them through 2 different output speakers. One from the hololens speaker and the other through my laptop speakers. So I tried: ```
private void SetAudioOutputToHoloLens()
{
int numDrivers = 0;
fmodSystem.getNumDrivers(out numDrivers);

    // Check if there are available devices
    if (numDrivers > 0)
    {
        string hololensDeviceName = "Speakers (Mixed Reality Audio Driver)"; 
        for (int i = 0; i < numDrivers; i++)
        {
            string driverName;
            int driverNameLength = 256;
            System.Guid guid;
            int systemRate;
            SPEAKERMODE speakerMode;
            int speakerModeChannels;

            // Get driver info for the current device
            fmodSystem.getDriverInfo(i, out driverName, driverNameLength, out guid, out systemRate, out speakerMode, out speakerModeChannels);

            // Log the driver name for debugging purposes
            UnityEngine.Debug.Log("Driver " + i + ": " + driverName);

            if (driverName == hololensDeviceName)
            {
                // Set this driver as the output device for FMOD
                fmodSystem.setDriver(i);
                UnityEngine.Debug.Log("Set audio output to HoloLens device.");
                break;
            }
        }
    }
    else
    {
        UnityEngine.Debug.LogError("No audio devices found.");
    }
}

However, neither the laptop speakers nor the hololens speakers show up in the driver list. I’m not sure why. Can you please help?

The driver list should match the OS driver list, can you confirm that the OS device manager lists the speakers/outputs you are expecting?

The laptop speakers are on the OS driver list (Speakers Realtek(R) Audio) but the HoloLens is being used by the Holographic Remoting connection (wireless), so the HoloLens speakers aren’t in the list.
However, the laptop speakers still don’t show on the driver list.

Are you able to check the result from fmodSystem.getDriverInfo to see if there is an issue there?

That’s what I was using in the code (fmodSystem.getDriverInfo(i, out driverName, driverNameLength, out guid, out systemRate, out speakerMode, out speakerModeChannels);). It didn’t give me any errors but it also did not show the speakers.

Can you try enabling more logging in the FMOD Unity settings, setting the logging level to Log and enabling API error logging: