Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity3D Audio Latency in Android

I have read all posts about this problem on the internet and tried all advices. Though it seems that the problem (0.2-0.5 second latency to play an audio source) is caused by hardware or operating system on device according to people's sayings, I figured out that some applications play sound almost with a seemless delay (for example Perfect Piano).Anybody knows how to fix it?

like image 710
Namely Avatar asked May 18 '26 11:05

Namely


1 Answers

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. https://www.assetstore.unity3d.com/#!/content/107067


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 : http://exceed7.com/native-audio


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)

like image 156
5argon Avatar answered May 21 '26 00:05

5argon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!