PipeWire: Difference between revisions
m Turns out the ~ actually is required. Tags: Manual revert Visual edit |
m Fixed section hierarchy, add links to options and packages |
||
Line 22: | Line 22: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
It is possible to use the | It is possible to use the {{nixos:option|services.pipewire.extraConfig}} option hierarchy in NixOS to create drop-in configuration files, if needed. | ||
==Bluetooth Configuration== | ==Bluetooth Configuration== | ||
{{main|Bluetooth}} | |||
PipeWire can be configured to use specific codecs, by default all codecs and most connection modes are enabled, see [https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/bluetooth.html#monitor-properties this link] for precise details of which connections modes are enabled by default. The mSBC codec provides slightly better sound quality in calls than regular HFP/HSP, while the SBC-XQ provides better sound quality for audio listening. For more information [https://www.guyrutenberg.com/2021/03/11/replacing-pulseaudio-with-pipewire/ see this link]. | PipeWire can be configured to use specific codecs, by default all codecs and most connection modes are enabled, see [https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/bluetooth.html#monitor-properties this link] for precise details of which connections modes are enabled by default. The mSBC codec provides slightly better sound quality in calls than regular HFP/HSP, while the SBC-XQ provides better sound quality for audio listening. For more information [https://www.guyrutenberg.com/2021/03/11/replacing-pulseaudio-with-pipewire/ see this link]. | ||
Wireplumber ( | Wireplumber ({{nixos:option|services.pipewire.wireplumber}}) is the default modular session / policy manager for PipeWire in unstable. To add custom configuration you can use {{nixos:option|services.pipewire.wireplumber.extraConfig}} directly. For example: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
Line 57: | Line 60: | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight>Alternatively you can set | </syntaxhighlight>Alternatively you can set {{nixos:option|services.pipewire.wireplumber.configPackages}} as well, adding derivations that output wireplumber config files in <code>$out/share/wireplumber/wireplumber.conf.d/*.conf</code>: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
Line 109: | Line 112: | ||
All protocols (Pulseaudio/JACK) are now talking to the PipeWire protocol and are managed by the PipeWire daemon (therefore, applications can be managed by both Pulseaudio and JACK tools). For that reason, all graphical tools used for these protocols can be used: | All protocols (Pulseaudio/JACK) are now talking to the PipeWire protocol and are managed by the PipeWire daemon (therefore, applications can be managed by both Pulseaudio and JACK tools). For that reason, all graphical tools used for these protocols can be used: | ||
* pavucontrol: controls the volume (per-sink and per-app basis), the default outputs/inputs, the different profiles (for HDMI outputs/bluetooth devices), routes each application to a different input/output, etc. | * {{nixos:package|pavucontrol}}: controls the volume (per-sink and per-app basis), the default outputs/inputs, the different profiles (for HDMI outputs/bluetooth devices), routes each application to a different input/output, etc. | ||
* plasma-pa: a [[KDE|Plasma]] applet to change volume directly from the systray. Also deals with volume keys. | * {{nixos:package|kdePackages.plasma-pa}}: a [[KDE|Plasma]] applet to change volume directly from the systray. Also deals with volume keys. | ||
* qjackctl: with JACK emulation, provides a patchbay (to connect applications together). Note that JACK does not provide any way to change the volume of a single application; use Pulseaudio tools for that purpose. | * {{nixos:package|qjackctl}}: with JACK emulation, provides a patchbay (to connect applications together). Note that JACK does not provide any way to change the volume of a single application; use Pulseaudio tools for that purpose. | ||
* carla: with JACK emulation, provides a patchbay (make sure to go to "Patchbay" tab and check "Canvas > Show External"). | * {{nixos:package|carla}}: with JACK emulation, provides a patchbay (make sure to go to "Patchbay" tab and check "Canvas > Show External"). | ||
* catia/patchage: similar to qjackctl and carla. | * catia/{{nixos:package|patchage}}: similar to qjackctl and carla. | ||
* | * {{nixos:package|helvum}}: GTK-based patchbay for PipeWire (uses the PipeWire protocol). Volume control is planned for later. | ||
==Advanced Configuration== | ==Advanced Configuration== | ||
PipeWire can be extensively configured to fit the users' needs. Should the user want to do some fancy routing with null sinks, these can be defined directly in the config as shown below. | PipeWire can be extensively configured to fit the users' needs. | ||
=== Null sinks === | |||
Should the user want to do some fancy routing with null sinks, these can be defined directly in the config as shown below. | |||
This is especially convenient if the user has a multi-channel (8+, or something "weird" like 2x2, 3x2) soundcard that keeps confusing applications with too many channels or a bad channel layout. | This is especially convenient if the user has a multi-channel (8+, or something "weird" like 2x2, 3x2) soundcard that keeps confusing applications with too many channels or a bad channel layout. | ||
Line 175: | Line 181: | ||
In order to load the script on startup, it can be added to <code>~/.xprofile</code> or the specific DE/WM autostart config. Similarly, a one-shot user service can be created that runs the script. | In order to load the script on startup, it can be added to <code>~/.xprofile</code> or the specific DE/WM autostart config. Similarly, a one-shot user service can be created that runs the script. | ||
==Low-latency setup== | === Low-latency setup === | ||
Audio production and rhythm games require lower latency audio than general applications. PipeWire can achieve the required latency with much less CPU usage compared to PulseAudio, with the appropriate configuration. | Audio production and rhythm games require lower latency audio than general applications. PipeWire can achieve the required latency with much less CPU usage compared to PulseAudio, with the appropriate configuration. | ||
The minimum period size controls how small a buffer can be. The lower it is, the less latency there is. PipeWire has a value of 32/48000 by default, which amounts to 0.667ms. It can be brought lower if needed: | The minimum period size controls how small a buffer can be. The lower it is, the less latency there is. PipeWire has a value of 32/48000 by default, which amounts to 0.667ms. It can be brought lower if needed: | ||
Line 192: | Line 199: | ||
<strong>NOTE</strong>: Every setup is different, and a lot of factors determine your final latency, like CPU speed, RT/PREEMPTIVE kernels and soundcards supporting different audio formats. That's why 32/48000 isn't always a value that's going to work for everyone. The best way to get everything working is to keep increasing the quant value until you get no crackles (underruns) or until you get audio again (in case there wasn't any). This won't guarantee the lowest possible latency, but will provide a decent one paired with stable audio. | <strong>NOTE</strong>: Every setup is different, and a lot of factors determine your final latency, like CPU speed, RT/PREEMPTIVE kernels and soundcards supporting different audio formats. That's why 32/48000 isn't always a value that's going to work for everyone. The best way to get everything working is to keep increasing the quant value until you get no crackles (underruns) or until you get audio again (in case there wasn't any). This won't guarantee the lowest possible latency, but will provide a decent one paired with stable audio. | ||
===PulseAudio backend=== | ==== PulseAudio backend ==== | ||
Applications using the Pulse backend have a separate configuration. The default minimum value is 1024, so it needs to be tweaked if low-latency audio is desired. | Applications using the Pulse backend have a separate configuration. The default minimum value is 1024, so it needs to be tweaked if low-latency audio is desired. | ||
Line 245: | Line 252: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
==Headless operation== | === Headless operation === | ||
PipeWire can run on a headless device (without a GUI) such as a Raspberry Pi connected to a speaker. In that case, it may be preferable to start PipeWire on boot and keep it running rather than only running during an interactive login session. Among other things, this helps prevent a race condition that may occur when socket activation fails to initialize audio devices in time for their first use, leading to one-time errors after reboots. The following additional configuration facilitates this: | PipeWire can run on a headless device (without a GUI) such as a Raspberry Pi connected to a speaker. In that case, it may be preferable to start PipeWire on boot and keep it running rather than only running during an interactive login session. Among other things, this helps prevent a race condition that may occur when socket activation fails to initialize audio devices in time for their first use, leading to one-time errors after reboots. The following additional configuration facilitates this: | ||