Fix sound delay


I’m trying to play sounds on my android device, however they’re always delayed by about half a second. Why is that?

What you could do is Project Setting > Audio > DSP Buffer Size > set it to Best Latency (small buffer size). As of today with this settings, it make a glitched sound on Windows build while on macOS, Android, iOS is completely fine. You might want to have larger buffer size on Windows. (at the expense of more latency)

If “Best Latency” setting is still not enough for you going native is definitely the way to go. I just made Native Audio asset store plugins which can make a native call to both iOS and Android’s fastest native way from one central interface. Unity Asset Store - The Best Assets for Game Making

There are various ways of playing audio at native side, here’s my choice :

  • On iOS it uses OpenAL. It is faster than AVAudioPlayer, AudioToolbox, and SystemSound.
  • On Android it uses AudioTrack, I confirmed it to be faster than SoundPool and no meaningful difference from C++ side OpneSL ES of NDK.

I have compiled all of my findings in here : Native Audio - Unity Plugins by Exceed7 Experiments

PS. I have used FMOD for Unity before. The best settings that I could do. In addition to setting the best file format, requires editing FMOD Unity’s source code to use very low number of buffer size. With that still the latency is just about equal to Unity’s “Best Latency” (ant the sound cracks more too due to a low buffer size)

This is one setback of the Android OS in comparison to the iPhone/iOS all-inclusive atmosphere.

Because of the fact that there are simply so many different devices, the OS and the device are not always made to be one single cohesive item, if that makes any sense.

A Google search for ‘Android audio kernel’ will bring up most of the background information on the subject.

I’m not a fan of iPhone, but when it comes to audio latency in apps, it is actually superior.

This issue is mostly device-specific, but also has to do with processing. Are there background processes that can be eliminated.

How is your audio implemented in Unity? Are you using any middleware, etc.? An option you should select if possible is to pre-load the sample, instead of loading when encountered in the app.

Also, are you compressing your audio files to mp3 or an equivalent? Avoid using bulky WAV files, etc. if processing and latency are issues.

Hope this helps in some way.

It is unity doing fancy stuff with the audio, this is slow on Android.

I used this plugin to play sounds faster, its a bit limited in features:

Note that the link is broken in the original post, however, on page 2 I have uploaded the files.

thanks a lot!!!
Native Audio Native Audio - Unity Plugins by Exceed7 Experiments
我還沒試過 但是
上面這個連結貌似可以 是目前我看到的最新解決方案

ps建議用英文搜尋 較冷僻的問題用中文搜尋不好找到

I’m using Master Audio plugin on Unity. With a new game I’ve noticed about 500 ms latency on Samsung S8 which was very confusing since on some old devices that i have there were not noticable latency. DSP Buffer Size to low latency helped a little. Ignore time scale switcher in Master Audio helped a little. But the latency didn’t disapiear. So I’ve applied Native Audio plugin for Android and it works very well, but there is no such power and flexibility compare to Master Audio. And the only available sound quality for now is 16-bit PCM 44100Hz Stereo .wav which is not good for me. So what helped me to reduce the latency to about 100 ms i guess and made it acceptable for me is:

    private void PlaySoundAfterUpdate(string soundName)
        private IEnumerator PlaySoundAfterUpdateCoroutine(string soundName)
            yield return null;

In most cases i ve tried to play sound in OnCollisionEnter2D or FixedUpdate. After I’ve started to wait until next Update the latency reduced dramaticly. Still not so low as in Native Audio, but acceptable for me.
Hope it will help somebody.

I think u should change audio compressed format Vorbis to PCM. because unity default vorbis format is compressed itself when we add audio source in project this audio take little bit time for load because this Vorbis Audio try to compressed to decompressed in a project & PCM doesn’t but one cons in PCM this format take bigger size compare to defualt unity Vorbis. Pros is load faster than Vorbis.