I just installed a new linuxmint version (based on ubuntu 18.04 bionic).
I’m looking for jack_iodelay, but it is not in the repositories anymore! only jack_delay and jdelay are in the repository. I’m looking for jack_iodelay because it was updated and the output was much more understandable
Where is it ? Also I couldn’t find it anywhere on the internet… this is really strange! Did I miss something?
Thank you for the answer Paul!
It seems my fresh system installed jack2 by default.
Why jack_iodelay is not part of jack2 as well? Is it jack1 specific?
Any chance to have jack_iodelay also working in Jack2 ? or should I downgrade?
This is a long standing issue with the two versions of JACK. jack_iodelay is part of the tools/ folder of JACK1. It was intended that this folder would (eventually) be shared between both versions, but this never happened. As a result, JACK 2 has its version of jdelay (Fons’ original program), jack_delay, and JACK1 has its version, jack_iodelay. Each one will work with either version of JACK, but packaging in distributions will only give you one version.
You’re probably thinking of the include/ folder. The tools folder is shared between the two projects (it used to be copied into tree, but I think falktx did some recent merge to share it). On debian/stable:
With respect to Ardour: Don’t use JACK, use Ardour’s built-in ALSA backend. Ardour’s Engine Dialog has a GUI to measure latency and also allows to calibrate systemic MIDI latency per MIDI port.
Why should I use Alsa instead of Jack? I’m using Ardour with a Firewire RME800 and as far as I know I need to stick to Jack/FFADO. Could you please give me shortly the pros and cons?
I did the latency mesurement wit ardours’ build-in latency mesurement tool, but it didn’t work,even after a jack restart. But, after putting ardour’s latency mesurement values into qjackctl, it works perfectly.
My question is: Is there any in-depth documentation about the math and magic behind these latency mesurement and compensation? I really would like to write an article about this… because I was trying for ages to get it working and I would love to have a proper documentation about this somewhere on the internet. I tried some reverse-engineering, and I get the attended results, but with different period amount, and I get confused… looking at forums theads is also confusing because there are so many different answers.
Did you read the man-page of jack_iodelay? What would you add? Maybe just update the man page and add some “Example” section?
When it comes to users, I don’t think we need another article. We should provide some easy, self-explanatory tool to guide the user and get the measurement done. Ardour’s Engine-Dialog aims to provide that, but as you have found out, it is Ardour specific.
PS. I though the ALSA snd-fireface driver is already complete.
I completely agree about the users. But, actually I had a typical user-case: I installed a fresh new Linuxmint and installed jack (jack2 was installed by default). I wanted to start jack_iodelay but it was missing… only jack_delay and jdelay in the repositories. But jack_delay and jdelay don’t do the math for the -I and -O arguments. I got completely confused and started this thread. If an article was there to figure out all information in this thread, this would have been so helpful. Nethertheless, now we have this thread, I will gather all information in the next post.
I’d love to do that, where can I update the manpage?
I didn’t know about this I will try it asap, but unfortunately snd-fireface is not in my repositories (ubuntu bionic)…is there a ppa somewhere or should I compile it by myself?
Anyway, I keep forgetting that some people still have computers that can do firewire and don’t have access to ALSA drivers in 2019. I didn’t even consider that you don’t have access to this when I started commenting. Sorry.
JACK2 has 2 modes: the asynchronous mode (started by default) and the synchronous mode (needed to be started with -S): https://linuxmusicians.com/viewtopic.php?t=14000
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!)
Not quite – the original, upstream version is jack_delay – jack_iodelay is an older version of it that was forked to be shipped with both jack1 and jack2 and also does some basic division by two to show -I, -O params.
In any case I don’t think the history of the project matters at all when you want to calibrate latency.
I suggest to simply look up the port-latencies that jack sets jack_lsp -l instead of calculating the nominal buffersizes. It also includes sync/async mode settings. – also note however that you should start jack with -I0 -O0 to perform the calibration.
so about 1.75 meters. Why does this not show up in your initial calibration measurement?
Why don’t you use thethe loopback cable where you don’t have any additional latency to show that after calibration, re-recording the same signal aligns perfectly (+/- 1 sample)?
jackd does not allow to set systemic latencies while the device is running, and most for most USB devices the linux kernel-driver add some random systemic latency (internal buffering) every time the device is re-started. So with JACK and USB devices you can not usually get accurate alignment. – This is however USB specific (and the reason Ardour/ALSA allows to configure systemic latency without device restart).
thank you for the information and the improvements!
I updated the post so your input is in and changed the screenshot with a better result (using the loopback cable). And yes, you were completely right, the microphones were about 1.75 meter away from the speakers!
Last question: Does jack_iodelay knows about the JACK2 sync/async modes or it is just giving the JACK1/JACKsync values for -I and -O?
Yes jack takes sync/async mode as well as number of periods into account when setting the output port latency.
jack_iodelay also informs you about this when port-connections change. Look for new…latency messages. Here jack2 in async mode, 2 periods, 1024 fpp. When connecting it to system:playback/capture it shows:
new capture latency: [1024, 1024]
new playback latency: [2048, 2048]
Note however that any previously configured -I, -O options will also be included here. Make sure to set systemic latency to zero when performing the measurement!