!RIDICULOUS! Audio Latency - Android

Ok, so making my Physics ‘Puzzler’ I’ve run into what seems like a common issue. I’m getting Beefy delays in my Audioclips, only on Android. Of course, in editor there is no issue.

I read something about pre-buffering but found no info on how. The AngryBots tutorial on Android has no delays and from what I see, nothing special to make it work. I only have one audio clip! 44.1k mp3 at 16-bit PCM! …its 630ms long.

Other than ‘Best Latency’, is there anything I can do to reduce delays without writing a plugin or using FMOD? And does anyone have a resource on implementing SoundPool?

Getting a bit vexed. The size of my
file is 4.12KB!!! I’ve reduced it to
less than 300ms long soundclip. I
still get 0.5 second delay??

EDIT: So far the best latency on my device is achieved at (256, 2) output buffer. Seriously low values. Still ~300ms delay but better than 500ms!

for really short sounds i’d recommend WAV or some PCM variant. i’m fairly certain Unity/FMOD supports ADPCM which should get you 4:1 compressions and Audacity can export ADPCM formatted WAV files just fine.

also the latency fixes with Jelly Bean that the Android engineers showed at Google I/O only work on a few devices. that’s the biggest issue. you don’t really know if your app will be running on a quad core Snapdragon, or a dual core Rockchip ARM processor. this post has a bit more info as well as links for the Google presentation:

and the article mentions three devices that support the new low latency features:
from the article:
"So, which Android should you get (if any)?
…There are three devices that support the low latency profile, up from one device at Google I/O last year:

  1. Galaxy Nexus (Samsung)
  2. Nexus 4 (LG)
  3. Nexus 10 (Samsung)"

I’ve just released an asset that can help! It provides access to the native Android audio system, which removes most of the latency generated by Unity.

If “Best Latency” setting (small buffer size) 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)