PulseAudio: Difference between revisions

imported>Cluxter
Add sections about loading modules and about Bauer stereophonic-to-binaural DSP library (bs2b)
Pbek (talk | contribs)
Remove obsolete config example
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
PulseAudio is a popular sound server for Linux. It is now required by a number of applications, and should be enabled if audio support is desired on NixOS. Enabling PulseAudio is sufficient to enable audio support on NixOS in most cases.
PulseAudio is a popular sound server for Linux. A number of applications now expect a PulseAudio-compatible audio server.
 
As of NixOS 24.11, [[PipeWire]] is used over PulseAudio for most graphical sessions by default, but it can provide a PulseAudio-compatible server (see that page for more details). This page documents how to use "native" PulseAudio as an alternative.


==Enabling PulseAudio==
==Enabling PulseAudio==
Add to your configuration:
Add to your configuration:


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
hardware.pulseaudio.enable = true;
services.pipewire.enable = false;
hardware.pulseaudio.support32Bit = true;    ## If compatibility with 32-bit applications is desired.
services.pulseaudio.enable = true;
</syntaxHighlight>
services.pulseaudio.support32Bit = true;    # If compatibility with 32-bit applications is desired.
 
</syntaxhighlight>


You may need to add users to the <tt>audio</tt> group for them to be able to use audio devices:
You may need to add users to the <tt>audio</tt> group for them to be able to use audio devices:
Line 30: Line 34:
Or automatically:
Or automatically:
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
hardware.pulseaudio.extraConfig = "load-module module-combine-sink";
services.pulseaudio.extraConfig = "load-module module-combine-sink";
</syntaxHighlight>
</syntaxHighlight>


Line 36: Line 40:


<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
hardware.pulseaudio.extraConfig = "unload-module module-suspend-on-idle";
services.pulseaudio.extraConfig = "unload-module module-suspend-on-idle";
</syntaxHighlight>
</syntaxHighlight>


Line 83: Line 87:


<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
hardware.pulseaudio.package = pkgs.pulseaudioFull;
services.pulseaudio.package = pkgs.pulseaudioFull;
</syntaxHighlight>
</syntaxHighlight>


Line 101: Line 105:
To turn timer-based scheduling off add this to your configuration:
To turn timer-based scheduling off add this to your configuration:
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
hardware.pulseaudio.configFile = pkgs.runCommand "default.pa" {} ''
services.pulseaudio.configFile = pkgs.runCommand "default.pa" {} ''
   sed 's/module-udev-detect$/module-udev-detect tsched=0/' \
   sed 's/module-udev-detect$/module-udev-detect tsched=0/' \
     ${pkgs.pulseaudio}/etc/pulse/default.pa > $out
     ${pkgs.pulseaudio}/etc/pulse/default.pa > $out
Line 108: Line 112:
Then perform <code># nixos-rebuild switch</code>, followed by <code>$ pulseaudio -k</code>.
Then perform <code># nixos-rebuild switch</code>, followed by <code>$ pulseaudio -k</code>.


The difference should be directly noticeable. This is a known issue related to quality of Creative driver [https://guh.me/solving-creative-sound-blaster-x-fi-titanium-crackling-slash-distortion-on-linux], but it can also happen with other sound cards.
The difference should be directly noticeable. This is a known issue related to quality of Creative driver [https://guh.me/posts/2013-06-16-solving-creative-sound-blaster-x-fi-titanium-crackling-slash-distortion-on-linux/], but it can also happen with other sound cards.


=== Paprefs doesn't work on KDE ===
=== Paprefs doesn't work on KDE ===
Line 115: Line 119:
==See also==
==See also==
* [[Using JACK with PulseAudio]]
* [[Using JACK with PulseAudio]]
* [[PipeWire]]


[[Category:Audio]]
[[Category:Audio]]