How to use Android audio with low latency

Tae-Sung Shin picture Tae-Sung Shin · Dec 8, 2011 · Viewed 7.3k times · Source

Problem:

As you might have heard, Android does not provide with low latency audio API. What I mean by low latency audio is that you should be able to get audio signals from microphone and play the sound without much time gap in-between (e.g., 5-7 ms)

I've tried old java (with AudioRecord and AudioTrack) and "new" OpenSL ES. They are terrible and make app unusable.The issue was well documented here. BTW, iOS API can produce about 5-7 ms latency.

Looking for Workarounds:

But I am trying to do the low latency audio anyway. Something like this answer describes.

"However, I was only able to achieve this satisfactorily by writing my own code that did the mixing internally and accessed the low-level audio playback API only for playing the final mixed output. The higher-level ways of playing sounds in the .Net Compact Framework are theoretically capable of polyphony, but in practice they work horribly (lots of glitches, stuttering and distortion)."

Does this make sense for Android? An answer is discouraging.

So my question. Is there really no way to achieve 10 ms audio latency with Android?

To be honest, I am not expecting a solution in some time soon but just wish one great mind have answer to this problem.

Answer

numan salati picture numan salati · Mar 8, 2013

android 4.1+ has low latency audio api which should give you below 10ms latency. however the value varies by hardware (welcome to rich diverse world of android).

also feature descriptor of "android.hardware.audio.low_latency" can be used for filter out devices lacking low latency support.

check out http://www.youtube.com/watch?v=Yc8YrVc47TI&feature=player_de%20tailpage#t=1366s

and this: http://createdigitalmusic.com/2012/07/android-high-performance-audio-in-4-1-and-what-it-means-plus-libpd-goodness-today/