[HOW-TO] Measure the real round trip latency

Post fully complete "how to" guides and tutorials here. This is a great place to get feedback on stuff you might put in the wiki.

Moderators: khz, MattKingUSA

Post Reply
Established Member
Posts: 1270
Joined: Thu Apr 17, 2008 9:57 pm

[HOW-TO] Measure the real round trip latency

Post by Pablo »

There is a command line program that measures the round trip latency with a very high precision. The original program, jack_delay (aka, jdelay) was written by Fons Adriansen. Now it's part of JACK command line utilities. It will just work as long as you have a recent version of jack and it doesn't matter if it's jack2 (the default in most distros nowadays) or jack1.

The utility is called jack_iodelay and despite being CLI, it is very easy to use. The output is detailed but succinct.

Note that, in order to do the trick, jack_iodelay produces an unpleasant, loud sound. If you get things right the noise shouldn't get to the speakers but, just in case, turn down the speakers volume before you start.

Needless to say, I will assume that jack is up and running.

1) Physical connections

Firstly, you need to connect a physical cable between the output and the input of your soundcard. Normally, you will connect the first mono output (represented as system: playback1 in jack's terms) to the first mono input (what jack calls "system: capture1" in the software side).

2) Run jack_iodelay

Open a terminal and type: jack_iodelay . You will see something like:

Code: Select all

$ jack_iodelay 
new capture latency: [0, 0]
new playback latency: [0, 0]
Signal below threshold...
Signal below threshold...
Signal below threshold...

3) Connect jack_iodelay

Use you favourite jack connections manager and connect jack_delay: out to system: playback1. The signal is going through the cable to the first input, so now we have to close the loop: Connect system: capture1 to jack_delay: in

4) Understanding the numbers

You will see some numbers. In my test:

Code: Select all

 3106.619 frames     64.721 ms total roundtrip latency
	extra loopback latency: 34 frames
	use 17 for the backend arguments -I and -O
Here, the total round trip latency is 3106 frames approx. Divide this number by the jack sample rate in Hz and you have the latency in seconds. Anyway, as you can see, the calculation is done for you :) .

The "extra loopback latency" is latency not produced by jack itself. It is mainly down to the AD and DA converters in your soundcard. Here, the jack developers are recommening to put half the extra latency as "Input Latency" and the other half as "Output Latency". In qjackctl's setup, you can find these settings at the bottom of the right column. This way, jack-aware programs have the option to take it into account.

The rest of the latency depends, of course, on jack settings. In this test, I am running jack2 in the default, asynchronous mode, with 1024 frames per period and 2 periods per buffer. So, 1024*2 + 1024 = 3072 frames

Posts: 1
Joined: Wed Jul 11, 2012 2:09 am

Re: [HOW-TO] Measure the real round trip latency

Post by josephcarlosgonzales »

thanks for the links..

stroke therapy

Post Reply