
Mobile Audio Latency & Unity Android
As all mobile Unity app developers know, making an app that relies on audio response isn’t an easy task to do, due to Mobile Audio Latency.
Hopefully my steps on how I approached the challenge will help other Unity developers.
Improving Audio Latency
iPhones and iPads, in most cases, are just fine and will have great response by using the normal Unity Audio engine, but Android in the other hand, is quite a challenge.
First Phase Test
Create a normal button with an AudioSource Component and loaded AudioClip
Add a touch event to simply play the AudioClip with the AudioSource component
Build Android and iOS
You will notice that iOS will be fine and Android is quite disappointing.
Second Phase Test
After a lot of research & hair pulling, I managed to find a couple of gems.
- Superpowered SDK – A good read & understanding
- Android’s Native Sound Pooling
If you don’t have time to write your own Android plugin to get access to Android’s SoundPool – you can always buy this super handy asset from the Unity Asset Store : Android Native Audio
- Add an audio file to the StreamingAssets folder
- Create an audio pool via the SoundPool and add Audio file
- Create a normal button
- Add a touch event to play the audio file via the Android Plugin’s SoundPool
- Build Android
You will notice that the response time has greatly improved.
Even by using Android’s Sound Pool it will still have some latency, due to the hardware’s “round-trip” issue…
(Image Reference Superpowered SDK)
The Results
I used a Samsung Galaxy Note 4 for my Android testing VS an iPad Air – I got the same latency results. -This will definitely vary between Android devices.
Here is a Solo I made using my Rock Guitar Solo app :
If any one has a better approach please let me know 🙂