Ardour and pipewire-jack quantum/sample rate settings

Hi, I don’t know if this has already been discussed, but in Linux, when using pipewire-jack, you can customize the quantum/sample rate settings for each individual Jack client in the .config folder. This allows them to start with their own specific quantum/sample rate settings. This is especially useful if you don’t want all your programs to run with the same settings. For example, you might want to listen to audio from your browser, or from the Strawberry player, and also open a DAW. With individual settings, each program gets its intended quantum/sample rate settings. This prevents ALL programs from having to run with the same audio settings, as is the case when using a program like Cable, or when changing the system-wide values ​​via the terminal. Such changes are always system-wide. All programs, even if they don’t actually need them, then get the same settings, which leads to increased resource consumption and, of course, more frequent xruns.

Now to the actual problem: The above-mentioned procedure works very, very well with Qtractor and Hydrogen, for example, as well as with Firefox and several other programs, but unfortunately not at all with Ardour and the very outdated LMMS.

I don’t rule out that I’m doing something wrong myself, but by now I’m certain that the problem lies with the programs themselves. Yes, in Ardour you can directly select pipewire-jack in the settings and then also set the quantum. So far, so good. However, you can’t also set the sample rate there if you want to use pipewire-jack. Ardour always starts with the default pipewire setting, which is known to be 48,000 Hz. Changing the sample rate to 96,000 Hz for Ardour is only possible via a prior system-wide setting, which then affects every program.

Is this something that will change in the future?

If you have allowed 96000 in pipewire.conf, for example

default.clock.allowed-rates = [ 96000 48000 44100 ]

then something like this should be possible, start in terminal:

PIPEWIRE_LATENCY=128/96000 pw-jack ardour

or create a custom.conf in ~/.config/pipewire/jack.conf.d

# ~/.config/pipewire/jack.conf.d/custom.conf
 
jack.rules = [
    {
        matches = [
            {
                # all keys must match the value. ! negates. ~ starts regex.
                application.process.binary = "ardour"
            }
        ]
        actions = {
            update-props = {
                node.latency = 128/96000
            }
        }
    }
    {
        matches = [
            {
                client.name = "ARDOUR"
            }
        ]
        actions = {
            update-props = {
                jack.show-monitor = true
                jack.merge-monitor = false
            }
        }
    }
]

Side-note: pw-jack is a utility that really only has a purpose on systems where someone has decided not to make the pipewire implementation of JACK the default. If you’re using pipewire as your JACK server, the config file is the only current way to approach this.

As for the future, hard to say. The problem arises because if pipewire is being used, then from the POV of a JACK client, JACK is already running, and the JACK API does not allow changing sample rates (intentionally). You can only set the SR when starting JACK, but with pipewire running, it has already been (effectively) started for you.

It would be necessary to add some pipewire-specific code to set the SR, and we’re rather reluctant to do that.

That is counter to the way JACK is designed to work, so there may be issues to watch out for.
Although the examples you gave are not actually native JACK clients, so a browser would likely be using the Pulse API, not JACK, so would not have assumptions about JACK behavior inherent in the design like Ardour would. In that case extra buffering performed by the pipewire server to bridge between JACK and Pulse APIs would not cause any problem.

For applications which intentionally do use the JACK API you can set the quantum advertised by the JACK server using this utility:
pw metadata UI

That link is to a differnt post in the Ardour forums. The utility was originally developed by Glenn for MX Linux, but someone else broke it out separately and modified it slightly.

Haha, I’m almost embarrassed I posted that! :open_mouth:

In AV Linux I have moved to ‘Cable’ which is probably the most comprehensive PipeWire frontend in existence. The developer has made some use of LLM’s for developing assistance and has been up front about that but in my experience it works great and it is very actively developed:

1 Like

H.H,

I found a Linux script in YAD to change the sample rates quickly as needed. Found it to be very helpful to make changes. Hope it helps.

You will need to install YAD from your repository. Yad allows you to display GTK+ dialog boxes from command line or shell scripts. It is similar to Zenity but with more dialog types and options.

Cable works great too as Glen Mac Arthur suggested in his post.

Save the following script below to a file on your desktop and run…

#!/bin/bash
#Simple Yad Frontend to set Pipewire metadata
#broken out from AVLinux PipeWire Tools

IFS=‘|’ read -ra output <<<
$(yad
–form --columns=2
–field=“Quantum (bytes):CB” ‘’!64!128!256!512!1024!2048
–field=“Samples/sec.:CB” ‘’!44100!48000!88200!96000
–height=128
–width=480
–center
–title=“Set PipeWire Metadata”
–window-icon=preferences
–text=“Select Quantum (buffer size) and Sample Rate.
–text-align=center)\

pw-metadata -n settings 0 clock.force-quantum ${output[0]}
pw-metadata -n settings 0 clock.force-rate ${output[1]}

pw-metadata -n settings 2>&1 |
yad
–text-info
–width=540
–height=280
–center
–window-icon=preferences
–title=“Current PipeWire Metadata Settings”\

exit

I already have a pipewire.conf and pipewire-jack.conf that look like yours. The only difference is that I’ve also included qtractor, hydrogen, and LMMS in addition to Ardour. I specifically had to add an extra line because it doesn’t always work smoothly without it.

node.latency = 128/96000

→ node.force-quantum = 128

You could add another line, but that would switch the entire system back to a sample rate of 96000, and I want to avoid that.

→ node.force-rate = 96000

Using the same quantum value of 128 instead of the standard 1024 for different programs affects my system less than increasing globally the sample rate from the standard 48000 to 96000.

Qtractor needs “node.force-quantum = 128” because otherwise it starts at 64, and Hydrogen doesn’t need it. If I enter 256 in the .conf file for Qtractor, it starts at 128 even without the additional line. It’s strange, and I can’t figure it out, but it works. However, with Ardour and LMMS, the .conf files are completely useless. For example, I can only achieve 128/96000 if I first set the entire system to 128/96000 using Cable or a terminal command. But it’s also clear that it’s pointless to create a separate .conf file for each jack client if you’re going to set the whole system to the same quantum/sample rate anyway. You even lose the advantage that Pipewire offers, namely that each program can have different settings simultaneously.

This script sets the same values ​​for all programs, and that’s exactly what I didn’t want. Thanks!

My question specifically concerns the .conf file. As I’ve already described, the settings from the .conf file work with Qtractor and Hydrogen, but not with Ardour. Ardour always starts with the system’s default settings, regardless of the values ​​I’ve entered in the .conf file. I can easily configure quantum in Ardour, but since it’s not possible to adjust the sample rate, I’m using a .conf file that unfortunately doesn’t work with Ardour.

Thanks!

Cheers!

I didn’t want to run all programs with the same quantum/sample rate settings. Just like Cable, pw-methadata ui sets all programs on the system that use audio to the same quantum/sample rate.

Cheers!

I can’t answer that - Ardour itself doesn’t use the .conf file, that’s a pipewire thing.

Again, to reiterate: the JACK API provides no way to change the sample rate of a running JACK server (intentionally), so you could not do this (multiple clients at different rates) with JACK, and you certainly can’t do it with ALSA. You’re basically asking pipewire to resample everything (either for one client, or for all clients except one). That makes no sense to me.

It won’t do. You can set individual programs for different samples rates and buffers but pipewire only connects at the first one’s and each subsequent uses the first setting. The setting changes if the first program disconnects.

Thanks! So, at the moment, pipewire, or rather pipewire-jack, isn’t communicating correctly with Ardour. Then I can leave the .conf files as they are for now and accept that pipewire-jack and Ardour will only work together correctly if the settings are configured globally, for example, via Cable.

Cheers!