PulseAudio: Difference between revisions

From NixOS Wiki
imported>Makefu
m fix package name
imported>Cx405
Add fix for Creative sound cards. I am using it right now and it worked.
Line 48: Line 48:
$ nix-shell -p python27Full python27Packages.pyqt4 python27Packages.dbus-python --command qpaeq
$ nix-shell -p python27Full python27Packages.pyqt4 python27Packages.dbus-python --command qpaeq
</syntaxHighlight>
</syntaxHighlight>
== Clicking and Garbled Audio for Creative Sound Cards ==
If you own a sound card from Creative like X-Fi and you notice random clicks during audio playback, then add following to your configuration [https://github.com/NixOS/nixpkgs/issues/788#issuecomment-21707426]:
<syntaxHighlight lang="nix">
  hardware.pulseaudio.configFile = pkgs.runCommand "default.pa" {} ''
    sed 's/module-udev-detect$/module-udev-detect tsched=0/' \
      ${pkgs.pulseaudio}/etc/pulse/default.pa > $out
  '';
</syntaxHighlight>
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].


==See also==
==See also==

Revision as of 03:50, 24 June 2019

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.

Enabling PulseAudio

Add to your configuration:

hardware.pulseaudio.enable = true;
hardware.pulseaudio.support32Bit = true;    ## If compatibility with 32-bit applications is desired.

You may need to add users to the audio group for them to be able to use audio devices:

users.extraUsers.alice.extraGroups = [ "audio" ... ];

Troubleshooting PulseAudio

Before troubleshooting PulseAudio, determine that the kernel-level sound APIs (ALSA) are functional; see ALSA.

If ALSA-level audio is working, determine whether audio is being routed via PulseAudio.

To determine what processes are using the sound devices:

$ sudo lsof /dev/snd/*
COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
pulseaudi 14080 goibhniu   30u   CHR  116,7      0t0 5169 /dev/snd/controlC0
pulseaudi 14080 goibhniu   37u   CHR  116,7      0t0 5169 /dev/snd/controlC0

In this example, only pulseaudio processes are using sound devices.

If other processes (such as plugin-container) are using sound devices, this indicates they are bypassing PulseAudio; check that you don't have a local ~/.asoundrc file directing audio to somewhere else.

Explicit PulseAudio support in applications

Normally, the system-wide ALSA configuration (/etc/asound.conf) 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:

nixpkgs.config.pulseaudio = true;

Using Pulseaudio Equalizer

Currently (2017-11-29 #8384) the qpaeq command does not work out of the box, use the following commands to get it running:

$ pactl load-module module-equalizer-sink
$ pactl load-module module-dbus-protocol
$ nix-shell -p python27Full python27Packages.pyqt4 python27Packages.dbus-python --command qpaeq


Clicking and Garbled Audio for Creative Sound Cards

If you own a sound card from Creative like X-Fi and you notice random clicks during audio playback, then add following to your configuration [1]:

  hardware.pulseaudio.configFile = pkgs.runCommand "default.pa" {} ''
    sed 's/module-udev-detect$/module-udev-detect tsched=0/' \
      ${pkgs.pulseaudio}/etc/pulse/default.pa > $out
  '';

Then perform # nixos-rebuild switch, followed by $ pulseaudio -k.

The difference should be directly noticeable. This is a known issue related to quality of Creative driver [2].

See also