In-depth understanding of Jack and Latency measurement:
There are 2 versions of Jack. JACK1 and JACK2: https://github.com/jackaudio/jackaudio.github.com/wiki/Q_difference_jack1_jack2
JACK1 has a version number looking like 0.9.xx
JACK2 has a version number looking line 1.9.xx
To figure out the version u are using, type in a terminal:
There are 3 different latency measurement tools for Jack:
jdelay : the original dsp. Shows the latency result only in frames (samples)
jack_delay: it is packaged with JACK2. It shows the latency result in frames and in milliseconds.
jack_iodelay: it is packaged with JACK1. It shows the latency in frames, in milliseconds and gives the values for the latency compensation (-I and -O arguments for Jack)
Jack_iodelay Manpage: https://www.systutorials.com/docs/linux/man/1-jack_iodelay/
JACK2 has 2 modes: the asynchronous mode (started by default) and the synchronous mode (needed to be started with -S):
If you are using JACK2 and didn’t start it explicitly with sync mode (-S), then you are using it in async mode.
HOW TO figure out -I and -O values out of the latency mesurement in frames (samples):
JACK1 and JACK2 sync mode has the same buffer latency, while JACK2 async mode adds 1 latency period more.
- Calculate the full buffer size.
for JACK1 and JACK2 sync mode: n*p. aka frames/period * period/buffer
In my case: 1024 frames * 2 periods = 2048 frames (full buffer size for jack1 or jack2 sync mode)
for JACK2 async mode: (n*p)+1n. aka frames/period * period/buffer + 1xframes/period
In my case: 1024 frames * 2 + 1024 frames = 3072 (full buffer size for jack2 async mode)
It is also possible to get latency information with the
jack_lsp -l command instead of calculating it. This also includes sync/async mode settings of JACK2.
- Substract the full buffer size from the full roundtrip latency (measured by jdelay, jack_delay or jack_iodelay). Then divide by 2 to get -I and -O arguments.
In my case, if I use JACK1 or JACK2 sync mode:
4414 roundtrip latency - 2048 = 2366 frames.
-I and -O = 1183
In my case for JACK2 async mode:
4414 roundtrip latency - 3072 = 1342 frames.
-I and -O = 671
To calculates milliseconds, just divide the frames by your sample rate (in kHz).
Example: 1024 frames / 44.1kHz = 23.22 ms
You can put -I and -O also easily in qjackctl under:
Setup -> Advanced -> Latency I/O
- Make a test with Ardour.
- Record Ardour’s click on a reference track and the same click through the full roundtrip loop.
- Measure the latency with the selection tool.
- It should be as close as possible to the reference click track (on the picture below I achieved to have it at 12 samples only!)
I hope all this helps!
PS: See the posts below for more information!