Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Low latency audio api for Android?

Tags:

What are my options for playing simultaneous audio on an Android device with the least amount of latency? Am I going to get anything half decent out of the canned SDK, or is that asking too much? The documentation claims that the SoundPool class is capable of playing multiple sounds simultaneously with relatively good performance, but after running some tests in the emulator and on a physical device it seems pretty weak. Is there maybe a trick to it, or do I have to go to a much lower level api for this kind of thing? I've tried using a single sound pool with multiple samples loaded, and I've tried multiple sound pools each managing a single sample. I'm preloading everything, so that when I attempt to play back I have no additional code being executed other than the call to SoundPool.play().

like image 979
Rich Avatar asked Sep 19 '09 14:09

Rich


2 Answers

A number of people are interested in low-latency audio on Andriod. Here are the threads I'm following on the topic:

  • A wave covering audio related topics from this year's I/O conference.
  • An Android issue about support for low latency audio in the NDK.

This post suggests that Android devices have ALSA drivers (capable of low-latency audio)--but it seems that low-latency functionality isn't exposed to apps via the NDK.

I have no direct experience with Android, but from what I've read, low-latency (less than <10ms or so) isn't a reality yet. Please post any experience to the contrary!

like image 132
mattbh Avatar answered Oct 21 '22 07:10

mattbh


Android 2.3 now supports native access to audio APIs (via OpenSL) for low latency applications.

However, not all hardware devices will have the a low latency audio feature profile. Thus applications requiring low latency audio shouuld filter devices not supporting it in the Android market by specifying the following in the manifest:

<uses-feature android:name="android.hardware.audio.low_latency"/>
like image 42
dljava Avatar answered Oct 21 '22 06:10

dljava