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?
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.
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.