Latency problem in mac, slower than Unity AudioSource

Hello there,I come from China.Please forgive my poor English.

I’m working on a rhythm based game on Unity 2018.3 these days, and my friend recommended me to use FMOD.

So I downloaded FMOD Studio 1.10.10 and Unity integrations 1.10.10 . I found FMOD have so many powerful functions, but when I tried to use it, there is a really serious problem. LATENCY… I read many articles to solve the latency, such as:
-Close the “stream” switch in FMOD Studio’s Audio Bin
-Covert the Audio file from .wav to .mp3
-Add some code in FMODFMOD/RuntimeManager.cs “lowlevelSystem.setDSPBufferSize(256, 4);”

finally there is still some latency to play my sfx.

I have a simple test to the latency:

//here is my code
if (Input.GetKeyDown(KeyCode.K))
{
SoundController.Instance.FMODPlayOneShot(“SNARE”);
//call a FMOD’s PlayOneShot() to play a snare hit
}
if (Input.GetKeyDown(KeyCode.L))
{
SoundController.Instance.PlayAudioEffect(“SNARE”);
//use unity native AudioSource’s Play() to play the same clip
}

and when I press K and L at the same time,it comes out two separated sounds.
when I press K a little bit earlier, it sounds like one sound. I know latency is a complicated issue, but why FMOD is slower than Unity AudioSource?

thank you very much!

mardee

By using PlayOneShot() you are trying to do all the creation and triggering in the same call, this can slow things down, even more so when using streams.

To get the least latency at runtime, you will want to make sure that the event has been created and have had the bank/event sample data loaded well before it is started.

For example:
Start()

  • RuntimeManager.LoadBank(“bankName”, loadSampleData = true)
  • event = RuntimeManager.CreateInstance(“eventName”)

Later…

  • event.start()

This is a very simple way to set up an event, the wrapper functions like PlayOneShot are made for convenience over performance. We have more examples of scripting events in our docs:
https://fmod.com/resources/documentation-api?page=content/generated/engine_new_unity/script_example_basic.html#/

1 Like

thank you for the answer, but I’ve tried LoadBank and create event first, nothing improve.
last few days , I set the dspBufferSize to 256, and changed my audio from mp3 to ogg , it worked somehow, now the latency is much lower than before, though still slow than unity Audiosource.

new informations, I run my project on a windows PC, there is no latency , i think it’s mac’s issue.

Thanks for the info, we will have to do some further testing to see if we can locate the issue.