PipeWire: Difference between revisions
imported>Hypnosis2839 →Enabling PipeWire: clarify use of sound.enable |
imported>IgorM m Fixed syntax highlight issues |
||
Line 9: | Line 9: | ||
Add to your configuration: | Add to your configuration: | ||
<syntaxHighlight lang= | <syntaxHighlight lang=nix> | ||
# Remove sound.enable or set it to false if you had it set previously, as sound.enable is only meant for ALSA-based configurations | # Remove sound.enable or set it to false if you had it set previously, as sound.enable is only meant for ALSA-based configurations | ||
Line 26: | Line 26: | ||
The option definition <code>services.pipewire.config</code> no longer has any effect; overriding default Pipewire configuration through NixOS options never worked correctly and is no longer supported. Please create drop-in files in <code>/etc/pipewire/pipewire.conf.d/</code> to make the desired setting changes instead. For example, you can create a file <code>/etc/pipewire/pipewire.conf.d/pipewire.conf</code> with the contents | The option definition <code>services.pipewire.config</code> no longer has any effect; overriding default Pipewire configuration through NixOS options never worked correctly and is no longer supported. Please create drop-in files in <code>/etc/pipewire/pipewire.conf.d/</code> to make the desired setting changes instead. For example, you can create a file <code>/etc/pipewire/pipewire.conf.d/pipewire.conf</code> with the contents | ||
<syntaxHighlight> | <syntaxHighlight lang=text> | ||
context.properties = { | context.properties = { | ||
log.level = 5 | log.level = 5 | ||
Line 39: | Line 39: | ||
Wireplumber (<code>services.pipewire.wireplumber</code>) is the default modular session / policy manager for PipeWire in unstable, however there is currently no way to configure the advanced settings using the module. However, you can just drop the Lua files directly in the expected path (<code>/etc/wireplumber/bluetooth.lua.d</code>). For example: | Wireplumber (<code>services.pipewire.wireplumber</code>) is the default modular session / policy manager for PipeWire in unstable, however there is currently no way to configure the advanced settings using the module. However, you can just drop the Lua files directly in the expected path (<code>/etc/wireplumber/bluetooth.lua.d</code>). For example: | ||
<syntaxHighlight lang= | <syntaxHighlight lang=nix> | ||
environment.etc = { | environment.etc = { | ||
"wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = '' | "wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = '' | ||
Line 56: | Line 56: | ||
If you're still on 21.11 or enabled <code>pipewire-media-session</code> manually (by setting <code>services.pipewire.media-session.enable = true</code>), them you can use the module to configure it: | If you're still on 21.11 or enabled <code>pipewire-media-session</code> manually (by setting <code>services.pipewire.media-session.enable = true</code>), them you can use the module to configure it: | ||
<syntaxHighlight lang= | <syntaxHighlight lang=nix> | ||
services.pipewire = { | services.pipewire = { | ||
media-session.config.bluez-monitor.rules = [ | media-session.config.bluez-monitor.rules = [ | ||
Line 102: | Line 102: | ||
<strong>Note</strong>: those cards can be set to the "Pro Audio" profile with <code>pavucontrol</code> so PipeWire doesn't try to guess a wrong channel layout for them. | <strong>Note</strong>: those cards can be set to the "Pro Audio" profile with <code>pavucontrol</code> so PipeWire doesn't try to guess a wrong channel layout for them. | ||
<syntaxHighlight lang= | <syntaxHighlight lang=nix> | ||
environment.etc = let | environment.etc = let | ||
json = pkgs.formats.json {}; | json = pkgs.formats.json {}; | ||
Line 145: | Line 145: | ||
===Linking nodes=== | ===Linking nodes=== | ||
The config does not currently cover linking nodes together, but this can be fixed with a script. Soundcard names and ports should be replaced with the ones from the user's configuration: | The config does not currently cover linking nodes together, but this can be fixed with a script. Soundcard names and ports should be replaced with the ones from the user's configuration: | ||
<syntaxHighlight lang= | <syntaxHighlight lang=bash> | ||
#!/usr/bin/env bash | #!/usr/bin/env bash | ||
Line 161: | Line 161: | ||
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: | ||
<syntaxHighlight lang= | <syntaxHighlight lang=nix> | ||
environment.etc = { | environment.etc = { | ||
"pipewire/pipewire.conf.d/92-low-latency.conf".text = '' | "pipewire/pipewire.conf.d/92-low-latency.conf".text = '' | ||
Line 178: | Line 178: | ||
===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. | ||
<syntaxHighlight lang= | <syntaxHighlight lang=nix> | ||
environment.etc = let | environment.etc = let | ||
json = pkgs.formats.json {}; | json = pkgs.formats.json {}; | ||
Line 205: | Line 205: | ||
===Controlling the ALSA devices=== | ===Controlling the ALSA devices=== | ||
It is possible to configure various aspects of soundcards through PipeWire, including format, period size and batch mode: | It is possible to configure various aspects of soundcards through PipeWire, including format, period size and batch mode: | ||
<syntaxHighlight lang= | <syntaxHighlight lang=nix> | ||
environment.etc. | environment.etc. | ||
"wireplumber/main.lua.d/99-alsa-lowlatency.lua".text = '' | "wireplumber/main.lua.d/99-alsa-lowlatency.lua".text = '' | ||
Line 221: | Line 221: | ||
'';</syntaxHighlight> | '';</syntaxHighlight> | ||
The <code>matches</code> attribute applies the <code>actions</code> to the devices/properties listed there. It is usually used with soundcard names, like shown in the config above. <code><matches></code> can match any of the outputs of | The <code>matches</code> attribute applies the <code>actions</code> to the devices/properties listed there. It is usually used with soundcard names, like shown in the config above. <code><matches></code> can match any of the outputs of | ||
<syntaxHighlight lang= | <syntaxHighlight lang=console> | ||
$ pw-dump | grep node.name | grep alsa | $ pw-dump | grep node.name | grep alsa | ||
</syntaxHighlight> | </syntaxHighlight> |