- Home /
!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!
Ok, I've moved the Audio Listener right next to the sound (it was 400 Units away) and the delay is exactly the same. So sound does not appear to travel.
Do you have Audacity? Because using WAV sure saves memory! And thus, you might want to try converting your mp3 to a wav format (I hope you're not using $$anonymous$$ac). If you don't know how to use Audacity, I can tell you the steps.
Yeah Ive got it installed, just installed Lame today :/
Yeah I'll give that a shot, although 4.12 $$anonymous$$B is pretty damn small :P Can't believe Android is choking for half a second on that!
:D
Where'd dudes comment go? I see what he's asking now! :D Decompress on Load isn't there for WAV files!
They seem to be a lot bigger than $$anonymous$$P3 too.
The wav equivalent of my $$anonymous$$P3 is 37$$anonymous$$
Are you storing it in memory or strea$$anonymous$$g from disk?
Answer by metaphysician · Sep 14, 2013 at 09:48 AM
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)"
Ok, ill try these formats and see what happens.
Interestingly, running my quad core Xperia Z has audio lag in my own Unity game but not others. Also interesting to note is that a friends ancient Android 2.3 device has no lag at all.
Thanks for the information!
I've tried all the file types now. No difference on a any of them with respect to delay.
Answer by ChristopherCreates · May 02, 2015 at 03:14 PM
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.
http://u3d.as/content/christopher-creates/android-native-audio
Answer by 5argon · Apr 14, 2018 at 04:17 AM
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. 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)
Your answer
Follow this Question
Related Questions
Playing mp3 files on Android 1 Answer
Android audio delayed on some android devices 1 Answer
Major Latency on Android when using Microphone 1 Answer
Microphone Input Latency Android 1 Answer
android audio delayed 1 Answer