Measure audio latency

Given the difficulty of measuring input or output latency in isolation with custom hardware, audio latency is measured as round-trip latency, which represents the combined input and output latency.

Technique

The following steps are automated by the test software:

  1. The software generates a complex tone using short bursts of white noise of varying lengths, creating an easily recognizable structure.
  2. The device's audio output path plays the tone.
  3. The test loops back the audio output to an audio input.
    • For speaker and microphone paths, no additional hardware is needed as the built-in microphone records the sound played from the built-in speaker.
    • Analog 3.5 mm jacks use a custom Audio loopback dongle.
    • USB ports use either a USB to 3.5 mm adapter combined with the loopback dongle or a USB audio interface with cables connecting the output to the input.
  4. The test software records the looped-back audio.
  5. The test software employs a full-duplex stream to synchronize and simultaneously record both the output and input audio streams.

The following figure shows the test setup:

Measure audio latency

Figure 1. Measure audio latency.

Round-trip latency is determined by measuring the time offset between the output and input, using a normalized correlation algorithm to locate the output tone within the input stream.

The following figure shows how the round-trip latency is calculated:

Calculate round trip latency

Figure 2. Calculate round-trip latency.

See CTS Verifier audio peripherals for more information about the loopback hardware.

Test apps

This section describes two main apps for measuring latency. Both use identical techniques and are expected to yield comparable results.

OboeTester

OboeTester, a test suite designed for the Oboe library, offers valuable tests, including round-trip latency measurement.

You can get OboeTester in one of two ways:

Follow these steps to measure the latency on the OboeTester app:

  1. Launch OboeTester.
  2. Tap ROUND TRIP LATENCY.
  3. Tap MEASURE.
  4. Check the latency.msec value for the round-trip latency.

You can run this test using an Intent for Continuous Integration.

CTS Verifier

See the CTS Verifier Audio loopback latency test to determine if round-trip latency meets CDD requirements.