r/linuxaudio • • Mar 23 '17

Android: AAudio API for Pro Audio for high-performance, low-latency audio

https://android-developers.googleblog.com/2017/03/first-preview-of-android-o.html
9 Upvotes

9 comments sorted by

3

u/CptanPanic Mar 23 '17

Can't wait to see some benchmarks.

2

u/porl Mar 24 '17

Who wants to port Ardour for me?? 😂

2

u/[deleted] Mar 25 '17

As someone who just finished up an android audio app, I am very excited to hear about this! Tablet and and phone touchscreens can make for very satisfying musical experiences.

1

u/igorski81 Aug 20 '17

I maintain an open source audio engine for Android that was built on top of OpenSL. I have added a new driver that allows you to use AAudio as well.

I can only test on emulated devices so far, but I must say I like the API of AAudio (OpenSL works fine, but is quite a hassle to setup).

The library is written in C++ but exposes all actors to Java for quick and easy development.

It's also open for contributions and additions:

https://github.com/igorski/MWEngine

1

u/planethcom Sep 02 '17 edited Sep 02 '17

G-Stomper Studio, Rhythm and VA-Beast, all come with AAudio integration already (Android O only). So if anyone want to test the AAudio performance, feel free to check out one of these apps.

Once you've installed on of the apps, apply the following settings:

Main Screen / Setup / AUD / Audio System = AAudio

Main Screen / Setup / AUD / Internal Latency = Ultra Low

For best results, use the headphone jack audio output (not the internal speaker).

For now, the latency is pretty much the same as if the app uses Open SLES, but AAudio seems to be less CPU consuming than Open SLES. And the guys at Google improving AAudio with every Android revision. I'm sure it won't take long until Open SLES will fall behind.

Android 8.1 is already in progress, and so a probably even better AAudio backend.

0

u/[deleted] Mar 24 '17

[deleted]

2

u/jbfields Mar 24 '17

Which device has a touch screen with several hundred ms latency? That would be noticeable even in regular use. (For comparison, that's getting close to the amount of time required for a long press, which I believe is 500ms.)

Anecdotally, latency feels OK to me on my Nexus 6 and 9 with Grand Piano Free/Pro and with Music Synthesizer. Other apps I've tried have had noticeable latency. I haven't tried to measure it, though.

I've also plugged in a midi controller (with the help of a USB OTG adapter). Latency didn't seem much different, though again this is just subjective, I haven't measured it.

0

u/[deleted] Mar 24 '17

[deleted]

1

u/jbfields Mar 27 '17

Very interesting, thanks! But note that's 4 years old, and still only claiming "about 100ms", not several hundred milliseconds.

Googling around isn't finding me a lot of results from measuring touchscreen latencies. I should try to figure it out for my devices.

0

u/[deleted] Mar 27 '17

[deleted]

2

u/jbfields Mar 30 '17

Fair enough!

So, just for fun, I did an experiment:

Connect the headphone out from my nexus 9 to one input of my portable recorder (a Zoom H4n), connect a mic to the other, and put the mic right next to the screen. Start up "Music Synthesizer" (which seems subjectively to have OK latency). Tap a key. Open the resulting recording in Audacity, and look at the offset between the start of the two noises. Looks like the synth sound lagged the finger tap by about 45ms.

I also tried that with my Nexus 6, and got 50ms.

0

u/[deleted] Mar 30 '17

[deleted]

2

u/jbfields Mar 31 '17

I retried just now with exactly the same setup but using a midi controller instead of the touch screen (CME XKEY 25 plugged into each device with the help of a USB OTG adapter), and got about 20ms with the nexus 9, 35ms with the nexus 6.

I'd also like to compare to a hardware synthesizer, but unfortunately all I have at home is a digital piano, and I don't know what I'd even want to measure there. A piano doesn't sound the instant you touch the key--you're accelerating a hammer to throw it at a string (or in the digital case, you're accelerating a hammer-weight and triggering 2 or 3 sensors that are used to estimate velocity), so it sounds somewhere in the middle of the stroke.

In the end for an instrument I'm not sure the absolute amount of the latency matters as much as the variance--if you can predict with certainty when the sound's going to come, then you can learn to compensate (consciously or not). Also, I like to keep in mind that the speed of sound is about one foot per millisecond, so if you can tolerate playing with an amp 10 feet away from you, then you can tolerate 10ms of latency.