Namely
Namely

Reputation: 83

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?

Upvotes: 3

Views: 3674

Answers (2)

5argon
5argon

Reputation: 3863

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)

Upvotes: 3

Tricky Widget
Tricky Widget

Reputation: 117

I've written an asset that uses the native Android audio system for low-latency playback.

Check it out. :)

Asset Store: Android Native Audio

Upvotes: 0

Related Questions