Pipewire and JACK setup

So this post was requested by @sahaathvya over on Unfa’s Discord, discussing how to set up Pipewire for JACK aware applications

Let’s start with going over Pipewire – it’s another sound server for Linux, meaning there’s now 4 sound servers with Linux – Advanced Linux Sound Architecture (ALSA), PulseAudio, and JACK. ALSA came first, and then Pulse and JACK were built on top of it with two different goals – Pulse was primarily focused on consumer sound needs, with JACK (Jack Audio Connection Kit) being the pro-audio side. Eventually a bridge was developed so that JACK could feed audio into PA and vice-versa, but the bridge was clunky at best.

JACK and PA have limitations. They’re both limited to a single device – in the case of JACK, switching devices required restarting the entire sound server, which kills any task you had running with it, and the sink requires command line knowledge to configure beyond the 2in/2out default configuration.

Queue Pipewire. Pipewire solves this by creating a single, unified, low latency sound system for everything Linux! Right now, it is JACK and PulseAudio aware, so any application designed for those sound systems works out of the box. In the future, it will also be able to route video the way it routes audio, but for now, it’s focused on audio and MIDI. As you can see here on Pipewire’s wiki, the current setup with Pipewire outperforms JACK at all but the most extremely low latencies. As a jazz trained musician, I’m pretty sensitive to latency – it’s the difference between dragging and swinging notes, or nailing them right on the bet. I universally find that running Pipewire at 128 samples is plenty for me to be able to run Vital, or my rack setup in Carla for piano, with absolutely zero perceptible latency aside from my terrible piano skills.

Pipewire has some advantages to PulseAudio and JACK – for instance, latency can be configured on a per application basis, it will increase/decrease latency depending on error rates (with some caveats), and it can route directly from a PulseAudio source into a JACK source without the use of funky sinks – handy if you’re wanting to route Spotify through a tube/tape saturator to make your digital setup sound analog, or maybe you just want a compressor on your voice for Discord – much easier to do with Pipewire than with the previous incarnations of sound servers Linux has used.

If you’re running an Arch based distro (and have your system up to date), the Debian Bullseye or later, or Fedora 34, there’s no need to install pipewire as it is already running. I do recommend installing pipewire-jack-dropin (if you’re on an Arch based distro), or for non-arch users, simply uninstall JACK and that will force JACK aware applications to connect to Pipewire instead.

Now, the nitty gritty.

General pipewire configuration should be done by copying pipewire.conf from /usr/share/pipewire into ~./config/pipewire. I have mine set up to look like the following:

My custom pipewire configuration

So this means, my sound server runs at 48khz by default, with a 2048 buffer size and a maximum 2048 buffer size. That’s because at 4096, my USB interface (Behringer UMC1820 rackmount) starts having audio errors galore. The default minimum size is 32, but I have never used that low in my life – I start getting errors at 64, but decided I’d rather set it there than have 128 be the default minimum. I just didn’t like the look of 128 there in that spot (because that’s what matters in a configuration file, is how it looks), and felt it should be as low as I thought the computer might possibly be able to handle processing a simple sine wave.

For creating individual rules for JACK applications, copy jack.conf from /usr/share/pipewire to ~./config/pipewire, and at the bottom of the file, add your rules. Below is my copied example

jack.rules = [
{
matches = [
{client.name = "Carla"}
]
actions = {
update-props = {
node.latency = 128/48000
}
}
}
{
matches = [
{client.name = "Vital"}
]
actions = {
update-props = {
node.latency = 128/48000
}
}
}
{
matches = [
{client.name = "Zrythm"}
]
actions = {
update-props = {
node.latency = 1024/48000
}
}
}

]

WordPress makes the formatting of that difficult to read, so here’s a screenshot of the file in Kate

What does this do? Using the first rule as an example, it causes Pipewire to search for a client with the name “Carla” (client.name)and if it sees that client, it updates the properties (update-props) to have a latency of 128 periods @ 48khz (node.latency = 128/48000). That value is hard coded, so if this gets you audio dropouts when you are playing, best set this higher.

I know what you’re saying right now. “But fusterclucker, you said there’s caveats?”

Sure is.

As you can see by my rules, I have Zrythm set to run at 1024, and Carla to run at 128. That means if I run Zrythm AND Carla (i.e. I’m using Carla for processing livestreaming vocals while I stream about Zrythm), then Zrythm’s going to use a period size of 128 and it’s going to have some issues because DAWS + 128 periods/buffer = audio dropouts galore on my machine. Ask how I know.

The second caveat, if you haven’t guessed it, is that there’s no GUI front end for this. I’m sure the Pipewire team has some idea of what to do for that but they haven’t let it slip, and although I’ve tried to make one, I’m having some difficulties solving the issue using the QT framework. You should come find me on Unfa’s Discord and ping me @fusterclucker if you have a solution for this.

Finally, the third caveat is that this is still in development. Manjaro’s community repos are consistently 1 version behind the current master branch, and I can’t testify to other distros as far as the current pipewire package versions. The devs are super responsive to bugs and inquiries (although sometimes their responses are predictably, “RTFD” as I have experienced), and the state of Pipewire is rapidly improving. I started using Pipewire full-time for audio production about 6 months ago, and in that time they’ve added JACK transport (although it’s currently kinda borked as of the writing of this post), JACK freewheeling support (this works exactly like JACK), and tons of bug fixes.

As always, thanks for reading, and if you enjoyed this, I encourage you to go find my YouTube channel, Insta, or on Mastodon – @fusterclucker@mastodon.online – and subscribe to any of the above.

Leave a Reply