PulseAudio: Difference between revisions
imported>Haizaar No edit summary |
Remove obsolete config example |
||
| (8 intermediate revisions by 7 users not shown) | |||
| Line 1: | Line 1: | ||
PulseAudio is a popular sound server for Linux. | 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"> | ||
services.pipewire.enable = false; | |||
services.pulseaudio.enable = true; | |||
</ | 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 15: | Line 19: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
==Explicit PulseAudio support in applications== | == Explicit PulseAudio support in applications == | ||
Normally, the system-wide ALSA configuration (<tt>/etc/asound.conf</tt>) redirects the audio of applications which use the ALSA API through PulseAudio. For this reason, most applications do not need to be PulseAudio-aware. Some NixOS packages can be built with explicit PulseAudio support which is disabled by default. This support can be enabled in all applicable packages by setting: | Normally, the system-wide ALSA configuration (<tt>/etc/asound.conf</tt>) redirects the audio of applications which use the ALSA API through PulseAudio. For this reason, most applications do not need to be PulseAudio-aware. Some NixOS packages can be built with explicit PulseAudio support which is disabled by default. This support can be enabled in all applicable packages by setting: | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
nixpkgs.config.pulseaudio = true; | nixpkgs.config.pulseaudio = true; | ||
</syntaxHighlight> | |||
== Enabling modules == | |||
Modules can be loaded manually: | |||
<syntaxHighlight lang="sh"> | |||
pactl load-module module-combine-sink | |||
</syntaxHighlight> | |||
Or automatically: | |||
<syntaxHighlight lang="nix"> | |||
services.pulseaudio.extraConfig = "load-module module-combine-sink"; | |||
</syntaxHighlight> | </syntaxHighlight> | ||
| Line 25: | Line 40: | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
services.pulseaudio.extraConfig = "unload-module module-suspend-on-idle"; | |||
</syntaxHighlight> | </syntaxHighlight> | ||
| Line 36: | Line 51: | ||
$ nix-shell -p python27Full python27Packages.pyqt4 python27Packages.dbus-python --command qpaeq | $ nix-shell -p python27Full python27Packages.pyqt4 python27Packages.dbus-python --command qpaeq | ||
</syntaxHighlight> | </syntaxHighlight> | ||
== Using Bauer stereophonic-to-binaural DSP library == | |||
This module re-creates on a headset what you would hear in real-life, improving sound quality and decreasing brain fatigue. | |||
See the description of the project for more details: https://bs2b.sourceforge.net/ | |||
The nix package to use is: <code>libbs2b</code> | |||
<b>FIXME</b>: getting an error while running: | |||
<syntaxHighlight lang=console> | |||
$ pactl load-module module-ladspa-sink sink_name=binaural master=bluez_sink.AA_BB_CC_DD_EE_FF.a2dp_sink plugin=bs2b label=bs2b control=700,4.5 | |||
</syntaxHighlight> | |||
== Troubleshooting == | == Troubleshooting == | ||
| Line 59: | Line 87: | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
services.pulseaudio.package = pkgs.pulseaudioFull; | |||
</syntaxHighlight> | </syntaxHighlight> | ||
| Line 77: | 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"> | ||
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 84: | 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 91: | Line 119: | ||
==See also== | ==See also== | ||
* [[Using JACK with PulseAudio]] | * [[Using JACK with PulseAudio]] | ||
* [[PipeWire]] | |||
[[Category:Audio]] | [[Category:Audio]] | ||