pipewire latency compensation roundtrip

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
timark
Established Member
Posts: 8
Joined: Thu Feb 22, 2024 9:38 pm

pipewire latency compensation roundtrip

Post by timark »

Hey guys,

is there a easy and proper way to calibrate pw-jack with the jack-iodelay results. So its usable for ardour?

cheers,
Tim

spicate
Posts: 1
Joined: Fri Feb 23, 2024 7:35 am

Re: pipewire latency compensation roundtrip

Post by spicate »

there is a way to calibrate pw-jack with the jack-iodelay results, but it may not be very easy or proper. Here are the steps that I found:

• Run pw-jack jack_iodelay and connect its output port to its input port using a patchbay like QjackCtl or Carla. You should hear some annoying tones and see the measured latency in the terminal.

• Subtract the JACK buffer size from the measured latency. The buffer size is determined by multiplying the number of frames per period by the number of periods per buffer. You can find these values in the PipeWire configuration file, usually located at /etc/pipewire/pipewire.conf.

• Divide the result by two and use that value for the input and output latency arguments of pw-jack. You can pass these arguments using the -I and -O options when launching pw-jack. For example, if the result is 20 ms, you can use -I 10 -O 10https://discourse.ardour.org/t/jack-iodelay-is-giving-wrong-results/104298.

• Restart pw-jack with the new arguments and check if the latency is compensated in Ardour. You can use the latency measurement tool in Ardour to verify the results.

You don't have to forget and forgive to move ongeometry dash

User avatar
LAM
Established Member
Posts: 992
Joined: Thu Oct 08, 2020 3:16 pm
Has thanked: 141 times
Been thanked: 348 times

Re: pipewire latency compensation roundtrip

Post by LAM »

I don't know if something changed on the PW side, but it doesn't look particularly "user friendly":

https://discourse.ardour.org/t/how-does ... /107381/12

in mix, nobody can hear your screen

timark
Established Member
Posts: 8
Joined: Thu Feb 22, 2024 9:38 pm

Re: pipewire latency compensation roundtrip

Post by timark »

Thanks, I have switched back to jack2. jack_delay shows me 1703,675 frames and 38,632 ms in a continuous loop. But no extra looback latency.

qjackctl is configured with 44100hz/256frames/3buffers and shows me a latency of 17.4ms.

How do I calculate the extra loop latency?

Abu-alhassan
Posts: 1
Joined: Sat Feb 24, 2024 3:49 pm
Has thanked: 1 time

Re: pipewire latency compensation roundtrip

Post by Abu-alhassan »

I,m using Ubuntu studio 23.10 with and they have configuration tool GUI from which you can set the buffer size and sample rate I set the buffer to 128 and sample rate to 44100 on Ardour the latency show 2.9ms

Screenshot_٢٠٢٤٠٢٢٤_١٩١٠١٨.png
Screenshot_٢٠٢٤٠٢٢٤_١٩١٠١٨.png (26.05 KiB) Viewed 799 times
Screenshot_٢٠٢٤٠٢٢٤_١٩١١٤٤.png
Screenshot_٢٠٢٤٠٢٢٤_١٩١١٤٤.png (41.51 KiB) Viewed 799 times
Screenshot_٢٠٢٤٠٢٢٤_١٩٠٦٣١.png
Screenshot_٢٠٢٤٠٢٢٤_١٩٠٦٣١.png (84.24 KiB) Viewed 799 times
timark
Established Member
Posts: 8
Joined: Thu Feb 22, 2024 9:38 pm

Re: pipewire latency compensation roundtrip

Post by timark »

Hey Abu-alhassan,

thank you, but im looking for the roundtrip latency compensation. The roundtrip latency is a additional due to eg ad/da converters and is not affected by jack.

magill
Established Member
Posts: 27
Joined: Wed Apr 05, 2023 9:11 am
Has thanked: 12 times
Been thanked: 9 times

Re: pipewire latency compensation roundtrip

Post by magill »

I missed that topic and I posted it somewhere else just moment ago so I'll just copy my message:

Latency compensation is perfectly possible in pipewire and it can be done globally through wireplumber ~/.config/wireplumber/main.lua.d/50-alsa-config.lua file as described here: https://pipewire.pages.freedesktop.org/ ... properties
It's also possible to put that setting in particular interface config.

My entry looks like this:
["latency.internal.rate"] = 120,
and it's important to add that coma at the end, as default config file had that omitted for some reason, otherwise wireplumber won't start. Maybe it's my system only, but I also had to do a reboot as restarting pipewire and wireplumber wouldn't register the change. (Although, pw-cli s <ID> ProcessLatency '{ rate = 120 }' works immediately and it's best for testing or quick adjustment).
Latency can also be set in nano seconds as explained in the above article.

Setting can be verified with:
pw-cli e <ID> ProcessLatency

Different DAWs deal with latency compensation differently so it's important to find value that works well in the DAW used. Reaper allows offsetting latency in options > preferences > recording so it not necessary to set it with latency.internal.rate at all. Different story with Ardour. It has a nice tool to set latency for Alsa back-end but not for jack or pipewire. It's where jack's -I/-O switches and pipewire's latency.internal.rate come in handy.

oddy.o.lynx
Established Member
Posts: 115
Joined: Sat Jun 30, 2018 2:54 am
Has thanked: 22 times
Been thanked: 22 times

Re: pipewire latency compensation roundtrip

Post by oddy.o.lynx »

magill wrote: Sat Feb 24, 2024 8:39 pm

Latency compensation is perfectly possible in pipewire and it can be done globally through wireplumber ~/.config/wireplumber/main.lua.d/50-alsa-config.lua file as described here: https://pipewire.pages.freedesktop.org/ ... properties
It's also possible to put that setting in particular interface config.

That link is incomplete and gives a 404 The page you're looking for could not be found. error.

User avatar
LAM
Established Member
Posts: 992
Joined: Thu Oct 08, 2020 3:16 pm
Has thanked: 141 times
Been thanked: 348 times

Re: pipewire latency compensation roundtrip

Post by LAM »

in mix, nobody can hear your screen

timark
Established Member
Posts: 8
Joined: Thu Feb 22, 2024 9:38 pm

Re: pipewire latency compensation roundtrip

Post by timark »

Great! @magill, is it based on the measurement from jack_delay?

magill
Established Member
Posts: 27
Joined: Wed Apr 05, 2023 9:11 am
Has thanked: 12 times
Been thanked: 9 times

Re: pipewire latency compensation roundtrip

Post by magill »

timark wrote: Sun Feb 25, 2024 12:20 pm

Great! @magill, is it based on the measurement from jack_delay?

Partially yes, but you would have to subtract software latency that your DAW should be aware of (both, Ardour and Reaper show it in top right corner) from what jack_delay measures. That should give you some estimate but I think it's best to perfect it with a click track method.
One annoying thing is that overall latency will fluctuate with USB audio devices and it can be noticed with jack_delay, especially when there is some load or xruns. For me it can be between anywhere between 7 and 9ms when 96 buffer size is used. I don't think there is a workaround, as it's a kernel thing apparently, but for my workflow it's small enough to ignore.

User avatar
TheYke
Established Member
Posts: 53
Joined: Mon Dec 16, 2019 3:57 pm
Been thanked: 6 times

Re: pipewire latency compensation roundtrip

Post by TheYke »

On my setup roundtrip latency is dependent on the selected buffer size, so better check that. That means that maybe you have to reset the latency every time you change buffersize. If you know the node-id of your input and output port, you can set the latency compensation value with pw-cli as follows:

Code: Select all

pw-cli s 48 ProcessLatency '{ rate=46 }'; pw-cli s 49 ProcessLatency '{ rate=46 }';

Here,"48" and "49" are the node-id's of my input and output, and I set both to a latency of "46". I did it via trial and error as the fluctuation is not too bad and managed to get nearly sample accurate latency compansation.

timark
Established Member
Posts: 8
Joined: Thu Feb 22, 2024 9:38 pm

Re: pipewire latency compensation roundtrip

Post by timark »

I switched for recording and mixing back to jack and use the pipewire-jack bridge for other stuff under arch. Works great. :D

Post Reply