Ubuntu 21.04 and Pipewire

What other apps and distros do you use to round out your studio?

Moderators: MattKingUSA, khz

Post Reply
kraus
Established Member
Posts: 11
Joined: Mon Aug 10, 2020 8:12 pm
Has thanked: 2 times

Ubuntu 21.04 and Pipewire

Post by kraus »

Someone had to do it. I figured it might as well be me!

I have Ubuntu 21.04 running on a Live USB drive just to play with PipeWire, and I was pleasantly surprised to see PipeWire's service running right out of the box.

Code: Select all

ubuntu@ubuntu:~$ systemctl --user status pipewire.service
● pipewire.service - Multimedia Service
     Loaded: loaded (/usr/lib/systemd/user/pipewire.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-04-22 22:05:32 UTC; 1h 56min ago
TriggeredBy: ● pipewire.socket
   Main PID: 2064 (pipewire)
     CGroup: /user.slice/user-999.slice/user@999.service/session.slice/pipewire.service
             └─2064 /usr/bin/pipewire

Apr 22 22:05:32 ubuntu systemd[2055]: Started Multimedia Service.
Ubuntu's Audio Settings show my Audio Interface, and the audio tests work.

Screenshot from 2021-04-23 00-25-07.png
Screenshot from 2021-04-23 00-25-07.png (35.55 KiB) Viewed 4850 times

But when I open Carla, the patchbay appears blank.
Screenshot from 2021-04-23 00-21-46.png
Screenshot from 2021-04-23 00-21-46.png (11.29 KiB) Viewed 4850 times

I found this four month old blog post . His blog post is before today's Ubuntu 21.04 release. It explains he used pw-jack carla to make it work, so I tried that but it is showing generic 2-channel inputs and outputs.

Code: Select all

$ sudo apt install pipewire-audio-client-libraries
$ pw-jack carla
Carla 2.3.0 started, status:
  Python version: 3.9.4
  Qt version:     5.15.2
  PyQt version:   5.15.4
  Binary dir:     /usr/lib/carla
  Resources dir:  /usr/share/carla/resources
Frontend pixel ratio is 1.0
libjack.so.0 loaded successfully!
Carla assertion failure: "ports != nullptr" in file CarlaEngineJack.cpp, line 3752
Screenshot from 2021-04-23 00-08-13.png
Screenshot from 2021-04-23 00-08-13.png (12.85 KiB) Viewed 4850 times

So, unlike the blogger's example, Carla is still unable to see my Scarlett. Even though Ubuntu sees my Scarlett, Carla does not. Not sure what to do at this point. Before I start poking around, manually editing configuration files, I'm wondering if there's a better way.

Edit: I found the Debian page on PipeWire which shows how to alleviate running pw-jack, which now allows JACK clients to run through PipeWire libraries by default, but does not solve the missing audio device issue:

Code: Select all

ubuntu@ubuntu:/etc/pipewire$ sudo touch /etc/pipewire/media-session.d/with-jack
ubuntu@ubuntu:~$ sudo cp /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf /etc/ld.so.conf.d/
ubuntu@ubuntu:~$ sudo ldconfig
kraus
Established Member
Posts: 11
Joined: Mon Aug 10, 2020 8:12 pm
Has thanked: 2 times

Re: Ubuntu 21.04 and Pipewire

Post by kraus »

I'm not sure if I found out "THE" solution, but... still, this is very interesting!

I went to Carla's Settings > Engine
  1. For "Audio driver," I switched it to "ALSA," then clicked the "..." button, and found my Scarlett was in the list. I selected that.
    Screenshot from 2021-04-23 01-18-37.png
    Screenshot from 2021-04-23 01-18-37.png (43.23 KiB) Viewed 4843 times
  2. Clicked "OK"
  3. Clicked "OK" to exit Settings
  4. Engine > Stop (Restarted the engine)
  5. Engine > Start
  6. And voila! It sees my Scarlett device.
    Screenshot from 2021-04-23 01-26-39.png
    Screenshot from 2021-04-23 01-26-39.png (55.74 KiB) Viewed 4843 times


While this makes my device appear, I don't think this actually fixes things...

It is not using JACK.

Why is this solution different than the one on the blog post?
What if I had multiple audio devices? The blogger's post shows he has multiple devices in his patchbay.

... And now I'm even more confused... after having shown my device in Audio Driver, it now no longer shows it. Now, instead of choosing it, if I select (default), Carla's patchbay shows all the appropriate inputs, but with constant Xruns....

On top of that, before this new revelation, I attempted to use Audacity, with no success recording... Then I tried using Ardour, and although ALSA's server seemed to load, I could not find the appropriate inputs and outputs, so could not record my mic through that.

On top of that, System audio is no longer playing. YouTube through Firefox, for instance. Videos won't start because audio isn't reachable...

I am even more confused now... Interesting stuff! But we are extremely confused...
kraus
Established Member
Posts: 11
Joined: Mon Aug 10, 2020 8:12 pm
Has thanked: 2 times

Re: Ubuntu 21.04 and Pipewire

Post by kraus »

Discovered how to properly configure this.

There are three services that need to be enabled.

It turns out the Debian team, while having packaged and enabled two of the three services, but left the final one in a /usr/share/doc/ folder. Debian still considers PipeWire to be "experimental" so leaves it to testers to fully enable it.

The doc where all of this is covered is https://wiki.debian.org/PipeWire. This is current as of Debian 11.

Yesterday in the middle of my ignorance and confusion I opened an issue thread on Pipewire's Gitlab. Then I was informed by a user on Freenode's #pipewire channel who explained the situation. In the thread, I posted what my final solution to configuring PipeWire for use on a Debian / Ubuntu distro.

1) If you intend on using anything JACK-related like Carla, Catia, etc, run these to get apps directly from KXStudios Repositories:

Code: Select all

sudo apt-get install apt-transport-https gpgv
wget https://launchpad.net/~kxstudio-debian/+archive/kxstudio/+files/kxstudio-repos_10.0.3_all.deb
sudo dpkg -i kxstudio-repos_10.0.3_all.deb
sudo apt update
sudo apt upgrade
2) Install the needed PipeWire libraries

Code: Select all

sudo apt install pipewire-audio-client-libraries
3) Run all the commands from Debian's PipeWire Wiki, one by one. These will:
  • create symlinks that invoke for PulseAudio, ALSA and JACK applications through PipeWire's server rather than their default ones, alleviating the need to run them through pw-jack <application>
  • disables pulseaudio.service and pulseaudio.socket, and replaces it with pipewire-pulse service and socket
  • checks to see if pactl is being run through PipeWire instead of PulseAudio.

Code: Select all

sudo touch /etc/pipewire/media-session.d/with-pulseaudio
sudo cp /usr/share/doc/pipewire/examples/systemd/user/pipewire-pulse.* /etc/systemd/user/
systemctl --user daemon-reload
systemctl --user --now disable pulseaudio.service pulseaudio.socket
systemctl --user --now enable pipewire pipewire-pulse
pactl info | grep '^Server Name'
sudo touch /etc/pipewire/media-session.d/with-alsa
sudo cp /usr/share/doc/pipewire/examples/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d/
sudo touch /etc/pipewire/media-session.d/with-jack
sudo cp /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf /etc/ld.so.conf.d/
sudo ldconfig
4) To keep pulseaudio.service from re-enabling on reboot, do this:

Code: Select all

systemctl --user mask pulseaudio
5) PipeWire services need to be restarted.

Code: Select all

systemctl --user restart pipewire.service
systemctl --user restart pipewire-pulse.service
systemctl --user restart pipewire-media-session.service
6) After that, install JACK and Pulse apps as desired! e.g.:

Code: Select all

sudo apt install pavucontrol
sudo apt install carla
etc, etc, etc.
Note, jackd will not be used with PipeWire, so does not need to be installed. If you're getting a message from an app that jackd will be installed (along with all its libraries) as dependencies, it's a good chance that that package has not been packaged properly to run with PipeWire.

After all of this is done, when you load Carla, it is important to change the Settings > Engine > Audio driver to JACK, and change Process Mode to "Single Client" or the proper devices on Patchbay will not be displayed.

Lastly, it's important to note that PipeWire is still being developed, and many modules are still needing to be built for every day musician use.
blockflute
Established Member
Posts: 41
Joined: Thu Apr 01, 2021 8:58 am
Has thanked: 6 times
Been thanked: 2 times

Re: Ubuntu 21.04 and Pipewire

Post by blockflute »

I'm at the total beginner stage with music on linux. I have fairly humble needs (though I know these can have a nasty habit of evolving). So far, I have got Ardour and Audacity working at the same time via Jack, and they are pretty much the only audio applications I use (apart from VLC). The final thing I need is to be able to get pulse audio working at the same time so I can watch youtube instruction videos while having Ardour running. It looks like I need pulse-jack bridging for that, but while tinkering around the edges of it I came across Pipewire and your post. Presumably, Pipewire will replace Jack in the longer term. I note you say that it's still in development and won't meet all requirements yet, but I think it would probably meet mine (and if/when I want more stuff, pw will have evolved by then). So, would you recommend bypassing the whole jack and pulse thing and going straight to Pipewire? I'm using Kubuntu 21.04 and Pipewire is indeed up and running on that.
kraus
Established Member
Posts: 11
Joined: Mon Aug 10, 2020 8:12 pm
Has thanked: 2 times

Re: Ubuntu 21.04 and Pipewire

Post by kraus »

Yeah, being on 21.04 is a good place to start, because no matter which way you go, it gives you access to the most up-to-date packages.

With PipeWire being so new, and with so many things rapidly progressing, being tested, additional modules either in the works or not yet started, if I had to recommend a starting place it would be with what's already fully developed, and that would be the traditional jack+pulse method.

I personally am still getting familiar with PulseAudio. Regarding JACK, I've barely scratched the surface. Right now I'm using QjackCtl and Carla for its patchbay view. Pipewire, while it has potential, just isn't fully "there" yet. That's my totally uneducated newbie opinion. I'm sure there will be some out there who say it's worth a shot, but the way I look at it, it's worth understanding the existing tech first before learning what's supposed to "replace" it.

TBH, PipeWire originally was supposed to be its own multimedia server for Video, then branched out to Audio, and the project expanded to look into covering all the bases that Pulse+JACK does now. While it says it's aiming to be extensive into the Pro Audio realm, covering all that JACK does, there are mixed opinions among several other musicians playing with it that pitfall after pitfall currently are blocking their way from fully utilizing it. So yeah, unless you're looking to venture into more uncharted territory, I would say stick with JACK, and bridge to Pulse where needed for those apps that can't support JACK yet.

As for making bridges, there are plentiful docs and threads on doing that. The newest way to do it is with JACK D-Bus, though there are limitations. Most features still in development as they work toward PulseAudio version 15. This means if you want to take advantage of them you would need to build PulseAudio from the source code, taken from the master branch at their gitlab project site, create a package, then deploy that. I messed with that on a VM using Manjaro and it's working, though I already found a memory bug, and quirky behaviour where certain functions don't work exactly as intended.

So, at this point the best way is to learn how to load jack modules, which means installing the pulseaudio-module-jack package (sudo apt install pulseaudio-module-jack) then checking out the Modules page on PulseAudio's wiki docs, and either putting those into default.pa or loading them manually through the pactl utility, or by creating a bash script to do that at login. It's a bit of work but it's one of those moments of satisfaction when you finally get it working. :)
User avatar
wjl
Established Member
Posts: 224
Joined: Fri Mar 17, 2017 12:27 pm
Location: near Frankfurt, Germany
Has thanked: 48 times
Been thanked: 26 times
Contact:

Re: Ubuntu 21.04 and Pipewire

Post by wjl »

blockflute wrote: Wed Apr 28, 2021 10:02 am The final thing I need is to be able to get pulse audio working at the same time so I can watch youtube instruction videos while having Ardour running. It looks like I need pulse-jack bridging for that, ...
You are right, and if you're still trying to get that bridge running, and have the KXStudio repositories, try Cadence instead of QJackCTL - it can set up that bridge automatically for you.

Now if you go Pipewire, I'm reading with interest, but am out at that point... (running Debian stable instead of the latest Ubuntu here)

Cheers,
Wolfgang
more about me on my blog
User avatar
Toejam76
Established Member
Posts: 138
Joined: Sat Jun 20, 2020 10:41 am
Has thanked: 15 times
Been thanked: 21 times

Re: Ubuntu 21.04 and Pipewire

Post by Toejam76 »

I'd like to recommend Cadence too. There is also Ubuntu Studio Controls, which can be installed afterwards on a Ubuntu system.
Using the KX repos and Ubuntu Studio ones can cause problems, because they both hold the same software in different versions and it confuses the package manager.
Attachments
Ubuntu Studio Controls.png
Ubuntu Studio Controls.png (78.95 KiB) Viewed 4760 times
cadence1.png
cadence1.png (46.09 KiB) Viewed 4760 times
Post Reply