Switching Void Linux Audio Server from PulseAudio to PipeWire

 2024-06-10

 Void Linux

This article is the English version of the article titled ‘Void LinuxのオーディオサーバーをPulseAudioからPireWireに切り替えてみた’.

Hello. The theme of this article is “Switching the audio server of Void Linux from PulseAudio to PireWire”. This article was verified with Void Linux, but I think it is probably possible to build a similar environment with Arch Linux.

What prompted me to introduce PireWire

I have been using PulseAudio as the audio server for my Linux desktop environment. There are many applications that support PulseAudio, and I have found it to be a great tool that allows you to play sounds normally without having to be aware of the audio server. In fact, I think PulseAudio is perfectly fine for web streaming and music players.

However, when I tried to run a DTM-related application, I encountered a situation where PulseAudio alone was not enough. Many DTM-related applications support an audio server called Jack, which is also known as “Pro Audio”. I looked into many sites and found that it was necessary to install Jack, and it seemed that some ingenuity was required, such as stopping PulseAudio during that time so that it would not interfere. (I have not tried an environment where Jack and PulseAudio coexist)

However, after further investigation, I found out that something called PipeWire is compatible with PulseAudio, Jack, and Alsa and functions as an audio server. If this is true, then PipeWire alone can fulfill both functions without installing Jack or PulseAudio. I thought so and decided to give it a try.

What is PipeWire?

PipeWire is a multimedia framework developed to capture video and audio with minimal delay, but it can also be used as an audio server like PulseAudio (it can also be used as a video capture server).

Its feature is that it works with applications that are compatible with PulseAudio, Jack, and Alsa. Normal audio applications are compatible with PulseAudio and Alsa. On the other hand, applications used in DTM often require Jack. There are still few applications designed to output directly to PipeWire, but it has the advantage of being able to use applications that are compatible with PulseAudio, Alsa, and Jack without switching audio servers. (If I’m wrong, please let me know.)

Uninstall PulseAudio

First, remove PulseAudio. Leave Pavucontrol, the GUI controller, in place, as it will still be used after installing PipeWire.

sudo xbpx-remove pluseaudio

Install PipeWire

Install PipeWire.

sudo xbps-install pipewire wireplumber

The session manager wireplumber should be installed automatically when installing the pipewire package, but I’ve included it in the command just in case.

Configure PipeWire

Set up before starting PipeWire. If you want to set it up for the entire system, place the configuration file under /etc/pipewire/, and if you want to set it up for each user, place the configuration file under ~/.config/pipewire/.

If you want to set it up for the entire system

Set it up as follows.

sudo mkdir -p /etc/pipewire/pipewire.conf.d
sudo ln -s /usr/share/examples/wireplumber/10-wireplumber.conf /etc/pipewire/pipewire.conf.d/

Setting for each user

Set as follows.

mkdir ~/.config/pipewire/pipewire.conf.d
ln -s /usr/share/examples/wireplumber/10-wireplumber.conf ~/.config/pipewire/pipewire.conf.d/

PipeWire startup test

Now let’s test whether PipeWire has been installed correctly. Start it with the following command.

pipewire

To check that it is running, use the wireplumber control command wpctl.

wpctl status

If the device and client are recognized as shown below, it is a success.

pipewire status

Setting autostart

Let’s set pipewire to start when starting the desktop environment. Use the autostart function of each desktop environment. Since the author’s current environment is labwc of the Wayland compositor, I wrote the following in ~/.config/labwc/autostart.

pipewire &

Introducing the PulseAudio interface

Many applications do not output to PipeWire. Therefore, by introducing an interface for PulseAudio, which is compatible with a wide range of applications, it will be possible to support PulseAudio applications.

sudo xbps-install pipewire-pulse

Configure to use the PulseAudio interface.

To configure for the entire system

sudo ln -s /usr/share/examples/pipewire/20-pipewire-pulse.conf /etc/pipewire/pipewire.conf.d/

To configure for each user

ln -s /usr/share/examples/pipewire/20-pipewire-pulse.conf /etc/pipewire/pipewire.conf.d/

Even after removing PulseAudio, you can still use Pavucontrol to adjust the volume with a GUI.

Integration with Alsa

We have covered many applications by making it compatible with PulseAudio, but there are also applications that only support Alsa, so we will integrate Alsa and Pipewire. Install alsa-pipewire.

sudo xbps-install alsa-pipewire

Configure as follows.

sudo mkdir -p /etc/alsa/conf.d
sudo ln -s /usr/share/alsa/alsa.conf.d/50-pipewire.conf /etc/alsa/conf.d
sudo ln -s /usr/share/alsa/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d

After this configuration, reboot the system.

Introduction of GUI tools

There are two GUI tools for PipeWire: Qpgraph and Helvum. In my personal opinion, Qpgraph is easier to use.

sudo xbps-install qpgraph

Using Bluetooth

Until now, I have been using PluseAudio to use audio with Bluetooth, but after switching to PipeWire, I need to install the libspa-bluetooth package. Install it with the following command.

sudo xbps-install libspa-bluetooth

After rebooting the system, check whether the Bluetooth headset that was previously connected can be connected.

Playing a sound

Now, let’s try playing a sound using Audacious. Audacious allows you to select multiple output options, such as Alsa, PulseAudio, PipeWire, etc. This time, we will set the output to PipeWire and check whether sound is produced.

pipewire status

While playing music with Audacious, open Qpgraph and try connecting to the Bluetooth headset Trekz Air by Aftershokz. To connect, just use the mouse to connect the wires on the GUI. It’s a very intuitive connection. You can also switch using Pavucontrol, the GUI controller for PulseAudio.

The figure below shows how Qpgraph is connected.

pipewire status

Can I use applications that require Jack without Jack?

Let’s try to see if you can use applications that use Jack without Jack if you have PipeWire, which we briefly introduced at the beginning. First, install libjack-pipwire with the following command.

sudo xbps-install libjack-pipwire

You should now be able to use the pw-jack command. If you can’t use it, try restarting your system. This time, we will use a synthesizer called Amsynth for testing. First, try starting Amsynth from the launcher as usual.

An error occurred.

pipewire status

Next, start Amsynth with the following command.

pw-jack amsynth &

This time it will start without any problems. Jack is recognized as the audio.

pipewire status

Let’s take a look at it in Qpgraph.

pipewire status

In this state, it was confirmed that sound would come out when pressing the play button on Amsynth. By starting the application after the pw-jack command, you can use the PipeWire Jack interface as an alternative to Jack. This allows the application to operate as if it has Jack even without Jack.

Summary

This time, we switched from PulseAudio to PipeWire. By making the settings described so far, applications that require PulseAudio, Alsa, and Jack can now be handled together in PipeWire. However, there are still some unknowns as to whether PipeWire can completely replace Jack. In the future, I would like to try out DTM-related applications and see if PipeWire is useful for Linux DTM.