How to measure sound delay using OpenSL on Android?

I use OpenSL to record and play sound on Android. Could you advise me how to measure the delay in order to find the optimal sound configuration (buffers, sample rate).

Thank you in advance!

+4
source share
4 answers

Here's how I used to measure audio output delay:

  • Create a simple user interface for your application with one or more buttons that play sounds when you click on them. I would suggest using sounds with an almost instant attack (that is, those that reach full amplitude very quickly).
  • Turn the volume on your Android device and hold it close to the microphone of another device (such as your PC or other phone).
  • Use your app to play some sounds by pressing buttons. Touch them hard enough to clearly hear the tap itself.
  • Record all this on the second device.
  • Once you're done, open the recording in a sound editor (e.g. Audacity) and measure the distance (i.e. time) between the click sounds and the resulting playback. You may want to take the average or average of several such distances.

This measurement method has the potential that is very easy to fulfill. The downside is that your result will also include touch latency. When sensing events occur at a frequency of 60 Hz, this will mean that in addition to delaying the audio output, you can get up to 16 ms of additional delay. This makes it virtually impossible to measure very small differences in delays using this method.


Update: On Glenn Casten’s Google inbox, he got in touch with several pages that described more accurate ways to measure sound delay. I decided that I could add them here for reference. Here is a page that describes the measurement of the round-trip delay, and here is another page that describes the measurement of the output delay only.

+8
source

Have you tried this app to measure it? https://play.google.com/store/apps/details?id=com.levien.audiobuffersize The application was created by Raf Levien from Google, and he creates a database with the results at http://audiobuffersize.appspot.com/ ( as you can see, there are many results already there) This is a fairly quick test that calculates the best buffer size and sample rate for your device and the lowest delay. How do I think that if many users upload their results, we can tell you how many / which devices are ready for low-latency sound ...

+4
source

Another very good way to test this is to also use the LED interface available through OpenSL | ES. Using this (and using LDR ) you can record the time between the LED and the emitted sound.

This is one of the methods that google people use when using them for their own devices. They go for it, and much more on the subject of low-frequency sound in android, in this video.

+1
source

Adding to @Michael method or detecting output delay. If you are interested in a round-trip delay, then there is a recording for playback. Then

1) just run a simple loop loopback application (make sure that buffering and queing are done correctly).

2) keep the volume preferably low to avoid feedback echo, but eccho should still be there and heard

3) now record the output through another microphone (PC) and make a touch sound, for example, by clicking with your fingers

4) import the sound from the second microphone (PC) onto the golden wave or courage and measure the delay between the latch and the latch played from the device

it will be your round trip

Although they will answer late, I hope this helps

hi shrish

+1
source

Source: https://habr.com/ru/post/1493589/


All Articles