Latency with Unity Integration and ASIO with errors Windows

Hello,
I am trying to improve the latency of the audio play, it is taking around 120ms. I wanted to try ASIO, to see if it improves.


On player settings/Audio I Disabled Unity Audio

On code I only have:

    FMODUnity.RuntimeManager.PlayOneShot("event:/beep"); 

However when I click Play on Unity these are the errors I get:

[FMOD] OutputWASAPI::init : IAudioClient::Initialize returned 0x8889000A.
[FMOD] Studio::System::initialize returned ERR_OUTPUT_INIT, defaulting to no-sound mode.
SystemNotInitializedException: [FMOD] Initialization failed : Output forced to NO SOUND mode : ERR_OUTPUT_INIT : Error initializing output device.

Do I have to code from script that I am going to use ASIO ? What should I do exactly?
How could I change the buffer sizes that will be used with ASIO?

When I change it to WASAPI everything is working fine, but with around 120 ms of delay.

Cheers

You changed the audio output mode of FMOD Studio only. Not unity.
When you selected ASIO it takes over the windows audio system, ie with exclusive audio control.
When you then ran unity (with WASAPI output as shown in the error messages) it failed because ASIO is holding control of the windows audio.

The best idea would be to alter the FMOD startup sequence in unity, and not adjust the FMOD Studio audio output mode.

During development you cannot have a WASAPI and ASIO application (or 2 ASIO applications) running simultaneously

Thanks for your answer Brett.
Could you please give me an example of how to do that in Unity script? or at least the commands I need to use for that? I only found the C++ examples in the documentation but I did not manage to find the classes and methods to select the output type to ASIO from unity.

I think it should be something similar to:

Studio::System::Create()

Studio::System::getLowLevelSystem()

Studio::System::getLowLevelSystem()->setOutput(FMOD_OUTPUTTYPE_ASIO));

Studio::System::initialize()

However I did not find the way to access those methods from c# Unity scripts.

That would mean I do not have to do anything from FMOD studio. I could leave it as WASAPI, since it will be changed from Unity C# script.
THANK YOU!

You could probably download the FMOD Unity integration, it has all the scripts used to set up fmod, and you could copy bits out of it if you are doing your own integration.

If anybody comes across this post, here are some snippets to do this. I modified RuntimeManager.cs for this:

      string sOutputType = pt.Settings.Config.GetString("Audio/OutputType", "AUTODETECT");
      try
      {
        outputType = (FMOD.OUTPUTTYPE)Enum.Parse(typeof(FMOD.OUTPUTTYPE), sOutputType);
        Debug.Log($"FMOD Initialize: Audio/OutputType setting is '{outputType}'");
      }
      catch (Exception e)
      {
        Debug.LogWarning($"Could not parse 'Audio/OutputType' enum of '{sOutputType}'; valid values are AUTODETECT, ASIO, WASAPI etc ({e.Message})");
      }
...
      result = FMOD.Studio.System.create(out studioSystem);
      CheckInitResult(result, "FMOD.Studio.System.create");

      result = studioSystem.getCoreSystem(out coreSystem);
      CheckInitResult(result, "FMOD.Studio.System.getCoreSystem");

      // Set desired OutputType BEFORE selecting a driver
      // This works better for ASIO for example (and e.g. Dante Virtual Soundcard)
      // since those are not detected with OutputType set to AUTODETECT
      result = coreSystem.setOutput(outputType);
      CheckInitResult(result, "FMOD.System.setOutput");