PipeWire: Hardware latency compensation?

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
robin
Established Member
Posts: 40
Joined: Wed Nov 04, 2020 10:56 am
Been thanked: 3 times

PipeWire: Hardware latency compensation?

Post by robin »

Hello there!
I gave Pipewire a shot and I am really impressed so far, will certainly switch my production system soon. One thing I could not bring over from JACK however is to account for extra-latency coming from hardware. Jack provided the option to pass down extra latency to Ardour, I could not find a way to do that in Pipewire. So when I record the click, the recording is late by a constant 11ms, no matter what I set as buffersize.
Ardour tells me the audio latency is 42.7ms, I/O latency is reported as 53.67ms, the difference being a suspicious 11ms. So it seems Ardour actually knows about it...
Any ideas how I can align those recordings?
glowrak guy
Established Member
Posts: 2315
Joined: Sat Jun 21, 2014 8:37 pm
Been thanked: 251 times

Re: PipeWire: Hardware latency compensation?

Post by glowrak guy »

First, you need to get the latency under 10ms. Should be easy if you post your distro and hardware details.
There is lots of info available, and common settings to configure. My out-of-the-box zero-config latency with AVLinux, based on debian MX Linux, is under 6 ms. It's an i7 3.4 ghz quadcore cpu, with mAudio pci soundcard, and an old pcie 9400 GT nVidia video card. If you're an Arch user, there is an excellent guide topic at the linux Reaper forum, aimed at Manjaro Arch spinoff, but with lots of info applying to linux audio in general:

https://forum.cockos.com/showthread.php?t=255313
robin
Established Member
Posts: 40
Joined: Wed Nov 04, 2020 10:56 am
Been thanked: 3 times

Re: PipeWire: Hardware latency compensation?

Post by robin »

I was actually asking about latency compensation, not how to avoid it. On my production system I use Jack with a buffersize of 128//48k, aka 2.7ms block latency. But the actual measured latency is 9ms, so the difference must be compensated for. This is possible by Jacks -I and -O switches. and I get spot on recordings. I'm looking for those switches on PipeWire.
5ms unhandled latency might not seem much, but it escalates quickly with many tracks...

P.S.: I'm totally fine with ~50ms latency now and then, either for mixing, or as long as its compensated for and I'm recording and using hardware monitoring ;)
magill
Established Member
Posts: 27
Joined: Wed Apr 05, 2023 9:11 am
Has thanked: 12 times
Been thanked: 9 times

Re: PipeWire: Hardware latency compensation?

Post by magill »

This an old topic but I was recently trying to find out myself so I'll post here, as information seems to be scattered all around and is sometimes confusing or outdated.

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.

Post Reply