Difference between revisions of "PulseAudio"

From ArchWiki
Jump to: navigation, search
(Music Player Daemon (MPD))
(Equalizer: Changed to warning, as can be seen on the Gentoo PA Wiki)
 
(366 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
[[Category:Audio/Video]]
 
 
[[Category:Sound]]
 
[[Category:Sound]]
 
[[cs:PulseAudio]]
 
[[cs:PulseAudio]]
Line 5: Line 4:
 
[[fr:PulseAudio]]
 
[[fr:PulseAudio]]
 
[[it:PulseAudio]]
 
[[it:PulseAudio]]
 +
[[ja:PulseAudio]]
 
[[pt:PulseAudio]]
 
[[pt:PulseAudio]]
 
[[ru:PulseAudio]]
 
[[ru:PulseAudio]]
 
[[tr:PulseAudio]]
 
[[tr:PulseAudio]]
[[Wikipedia:PulseAudio|PulseAudio]] is the default sound server that serves as a proxy to sound applications using existing kernel sound components like [[ALSA]] or [[OSS]]. Since [[ALSA]] is included in Arch Linux by default so the most common deployment scenarios include PulseAudio with [[ALSA]].
+
[[zh-CN:PulseAudio]]
 +
{{Related articles start}}
 +
{{Related|PulseAudio/Examples}}
 +
{{Related|PulseAudio/Troubleshooting}}
 +
{{Related articles end}}
 +
[[Wikipedia:PulseAudio|PulseAudio]] serves as a proxy to sound applications using existing kernel sound components like [[ALSA]] or [[OSS]]. Since ALSA is included in Arch Linux by default, the most common deployment scenarios include PulseAudio with ALSA.
  
{{Article summary start}}
+
== Installation ==
{{Article summary text|'''PulseAudio''' is a general purpose sound server. For a list of features, see [[Wikipedia:PulseAudio#Features]].}}
+
{{Article summary heading|Related Articles}}
+
{{Article summary wiki|PulseAudio/Examples}}
+
{{Article summary end}}
+
  
==Installation==
+
Install the {{Pkg|pulseaudio}} package.
*Required PKG:  {{Pkg|pulseaudio}}
+
*Optional GTK GUIs: {{Pkg|paprefs}} and {{Pkg|pavucontrol}}
+
*Optional volume control via mapped keyboard keys: {{AUR|pulseaudio_ctl}}
+
*Optional console mixer: {{AUR|ponymix-git}} and {{AUR|pamixer-git}}
+
*Optional system tray icon: {{AUR|pasystray-git}}
+
*Optional KDE plasma applet: {{Pkg|kdemultimedia-kmix}} and {{AUR|kdeplasma-applets-veromix}}
+
  
==Running==
+
Some PulseAudio modules have been [https://www.archlinux.org/news/pulseaudio-split/ split] from the main package and must be installed separately if needed:
{{Note|Pulseaudio requires [[D-Bus]] to function.}}
+
{{Note|Most X11 environments start pulseaudio automatically with the X11 session.}}
+
  
In the unlikely event that pulseaudio is not automatically called upon entering X, it can can be started with:
+
* {{Pkg|pulseaudio-bluetooth}}: Bluetooth (Bluez) support
$ pulseaudio --start
+
* {{Pkg|pulseaudio-equalizer}}: Equalizer sink (qpaeq)
 +
* {{Pkg|pulseaudio-gconf}}: GConf support (paprefs)
 +
* {{Pkg|pulseaudio-jack}}: JACK sink, source and jackdbus detection
 +
* {{Pkg|pulseaudio-lirc}}: Infrared (LIRC) volume control
 +
* {{Pkg|pulseaudio-xen}}: Xen paravirtual sink
 +
* {{Pkg|pulseaudio-zeroconf}}: Zeroconf (Avahi/DNS-SD) support
  
PulseAudio can be stopped with:
+
{{Note|Some confusion can be made between [[ALSA]] and PulseAudio. ALSA includes both Linux kernel component with sound card drivers, and a userspace component, {{ic|libalsa}}.[http://www.alsa-project.org/main/index.php/Download] PulseAudio builds only on the kernel component, but offers compatibility with {{ic|libalsa}} through {{Pkg|pulseaudio-alsa}}.[http://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/#index14h3]}}
$ pulseaudio --kill
+
  
==Equalizer==
+
=== Front-ends ===
  
Newer pulseaudio versions have an intergrated 10-band equalizer system. In order to use the equalizer do the following:
+
There is a number of front-ends available for controlling the PulseAudio daemon:
  
===Load equalizer sink module===
+
* GTK GUIs: {{Pkg|paprefs}} and {{Pkg|pavucontrol}}
 +
* Volume control via mapped keyboard keys: {{AUR|pulseaudio-ctl}}
 +
* Console (CLI) mixers: {{Pkg|ponymix}} and {{Pkg|pamixer}}
 +
* Console (curses) mixer: {{AUR|pulsemixer}}
 +
* Web volume control: [https://github.com/Siot/PaWebControl PaWebControl]
 +
* System tray icon: {{AUR|pasystray-git}}
 +
* KF5 plasma applet: {{Pkg|kmix}} and {{Pkg|plasma-pa}}
 +
* If you want to use Bluetooth Headsets or other Bluetooth Audio Devices together with PulseAudio see the [[Bluetooth headset]] Article.
  
$ pactl load-module module-equalizer-sink
+
== Configuration ==
  
===Install and run the gui frontend===
+
=== Configuration files ===
  
# pacman -S --needed python2-pyqt
+
{{Merge|PulseAudio/Configuration|Configuration should stay in the main article, so the linked page should be merged here. Split [[#Troubleshooting]] instead if this page is found too long.|section=Abandoned draft}}
 +
By default, PulseAudio is configured to automatically detect all sound cards and manage them. It takes control of all detected ALSA devices and redirect all audio streams to itself, making the PulseAudio daemon the central configuration point. The daemon should work mostly out of the box, only requiring a few minor tweaks.
  
$ qpaeq
+
PulseAudio will first look for configuration files in home directory {{ic|~/.config/pulse}}, then in system wide {{ic|/etc/pulse}}.
  
{{Note|If qpaeq has no effect, install pavucontrol and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.}}
+
PulseAudio runs as a server daemon that can run either system-wide or on per-user basis using a client/server architecture. The daemon by itself does nothing without its modules except to provide an API and host dynamically loaded modules. The audio routing and processing tasks are all handled by various modules. You can find a detailed list of all available modules at [http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/ Pulseaudio Loadable Modules]. To enable them you can just add a line {{ic|load-module <module-name-from-list>}} to {{ic|~/.config/pulse/default.pa}}.
  
===Load equalizer module on every boot===
+
{{Tip|
 +
* It is strongly suggested not to edit system wide configuration files, but rather edit user ones. Create the {{ic|~/.config/pulse}} directory, then copy the system configuration files into it and edit according to your need.
 +
* Make sure you keep user configuration in sync with changes to the packaged files in {{ic|/etc/pulse/}}. Otherwise, PulseAudio may refuse to start due to configuration errors.
 +
* There is usually no need to add your user to the {{ic|audio}} group, as PulseAudio uses [[udev]] and ''logind'' to give access dynamically to the currently "active" user. Exceptions would include running the machine headless so that there is no currently "active" user.}}
  
Edit the file {{ic|/etc/pulse/default.pa}} with your favorite editor and append the following lines:
+
==== daemon.conf ====
  
### Load the integrated pulseaudio equalizer module
+
Defines base settings like the default sample rates used by modules, resampling methods, realtime scheduling and various other settings related to the server process. These can not be changed at runtime without restarting the PulseAudio daemon. The defaults are sensible for most users.
load-module module-equalizer-sink
+
  
==Backend Configuration==
+
{{Note|PulseAudio does not perform tilde expansion on paths in this file. Use absolute paths for any files.}}
  
===ALSA===
+
{| class="wikitable"
*Recommended PKG: {{Pkg|pulseaudio-alsa}}
+
|+ Notable configuration options
*Optional PKGs: {{Pkg|lib32-libpulse}} and {{Pkg|lib32-alsa-plugins}}
+
! Option || Description
 +
|+
 +
| system-instance || Run the daemon as a system-wide instance. Highly discouraged as it can introduce security issues. Useful on (headless) systems that have no real local users. Defaults to {{ic|no}}.
 +
|+
 +
| resample-method || Which resampler to use when audio with incompatible sample rates needs to be passed between modules (e.g. playback of 96kHz audio on hardware which only supports 48kHz). The available resamplers can be listed with {{ic|$ pulseaudio --dump-resample-methods}}. Choose the best tradeoff between CPU usage and audio quality for the present use-case. {{Tip|In some cases PulseAudio will generate a high CPU load. This can happen when multiple streams are resampled (individually). If this is a common use-case in a workflow, it should be considered to create an additional sink at a matching sample rate which can then be fed into the main sink, resampling only once.}}
 +
|+
 +
| flat-volumes ||{{ic|flat-volumes}} scales the device-volume with the volume of the "loudest" application. For example, raising the VoIP call volume will raise the hardware volume and adjust the music-player volume so it stays where it was, without having to lower the volume of the music-player manually. Defaults to {{ic|yes}} upstream, but to {{ic|no}} within Arch. {{Note|The default behavior upstream can sometimes be confusing and some applications, unaware of this feature, can set their volume to 100% at startup, potentially blowing your speakers or your ears. This is why Arch defaults to the classic (ALSA) behavior by setting this to {{ic|no}}.}}
 +
|+
 +
| default-fragments || Audio samples are split into multiple fragments of {{ic|default-fragment-size-msec}} each. The larger the buffer is, the less likely audio will skip when the system is overloaded. On the downside this will increase the overall latency. Increase this value if you have issues.
 +
|}
  
{{Note|Optional PKGs are needed only if running x86_64 and wanting to have sound for 32 bit programs (like Wine).}}
+
==== default.pa ====
  
For the applications that do not support PulseAudio and support ALSA it is '''recommended''' to install the PulseAudio plugin for ALSA. This package also contains the necessary {{ic|/etc/asound.conf}} for configuring ALSA to use PulseAudio.
+
This file is a startup script and is used to configure modules. It is actually parsed and read after the daemon has finished initializing and additional commands can be sent at runtime using {{ic|$ pactl}} or {{ic|$ pacmd}}. The startup script can also be provided on the command line by starting PulseAudio in a terminal using {{ic|$ pulseaudio -nC}}. This will make the daemon load the CLI module and will accept the configuration directly from the command line, and output resulting information or error messages on the same terminal. This can be useful when debugging the daemon or just to test various modules before setting them permanently on disk. The manual page is quite self-explanatory, consult {{ic|man pulse-cli-syntax}} for the details of the syntax.
  
To prevent applications from using ALSA's OSS emulation and bypassing Pulseaudio (thereby preventing other applications from playing sound), make sure the module {{ic|snd_pcm_oss}} is not being loaded at boot. If it is currently loaded (<code>lsmod|grep oss</code>), disable it by executing:
+
{{tip|
# rmmod snd_pcm_oss
+
* Rather than being a complete copy, {{ic|~/.config/pulse/default.pa}} can start with the line {{ic|.include /etc/pulse/default.pa}} and then just override the defaults.
 +
* Run {{ic|<nowiki>$ pacmd list-sinks|egrep -i 'index:|name:'</nowiki>}} to list available sinks. The present default sink is marked with an asterisk.
 +
* Edit {{ic|~/.config/pulse/default.pa}} to insert/alter the set-default-sink command using the sink's name as the numbering cannot be guaranteed repeatable.
 +
}}
  
===ALSA/dmix without grabbing hardware device===
+
==== {{ic|client.conf}} ====
{{Note|This section describes alternative configuration, which is generally NOT recommended.}}
+
This is the configuration file read by every PulseAudio client application. It is used to configure runtime options for individual clients. It can be used to set and configure the default sink and source statically as well as allowing (or disallowing) clients to automatically start the server if not currently running.
  
You may want to use ALSA directly in most of your applications and to be able to use other applications, which constantly require PulseAudio at the same time. The following steps allow you to make PulseAudio use dmix instead of grabbing ALSA hardware device.
+
=== Configuration command ===
  
*Remove package {{Pkg|pulseaudio-alsa}}, which provides compatibility layer between ALSA applications and PulseAudio. After this your ALSA apps will use ALSA directly without being hooked by Pulse.
+
The main command to configure a server during runtime is {{ic|$ pacmd}}. Run {{ic|$ pacmd --help}} for a list options, or just run {{ic|$ pacmd}} to enter the shell interactive mode and {{ic|Ctrl+d}} to exit. All modifications will immediately be applied.
$ sudo pacman -R pulseaudio-alsa
+
  
*Edit {{ic|/etc/pulse/default.pa}}.
+
Once your new settings have been tested and meet your needs, edit the {{ic|default.pa}} accordingly to make the change persistent. See [[PulseAudio/Examples]] for some basic settings.
:Find and uncomment lines which load backend drivers. Add '''device''' parameters as follows. Then find and comment lines which load autodetect modules.
+
load-module module-alsa-sink '''device=dmix'''
+
load-module module-alsa-source '''device=dsnoop'''
+
# load-module module-udev-detect
+
# load-module module-detect
+
  
*''Optional:'' If you use {{Pkg|kdemultimedia-kmix}} you may want to control ALSA volume instead of PulseAudio volume:
+
{{Tip|leave the {{ic|load-module module-default-device-restore}} line in the {{ic|default.pa}} file untouched. It will allow you to restart the server in its default state, thus dismissing any wrong setting.}}
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.kde4/env/kmix_disable_pulse.sh
+
$ chmod +x ~/.kde4/env/kmix_disable_pulse.sh
+
  
*Now, reboot your computer and try running alsa and pulseaudio applications at the same time. They both should produce sound simultaneously.
+
It is important to understand that the "sources" (processes, capture devices) and "sinks" (sound cards, servers, other processes) accessible and selectable through PulseAudio depend upon the current hardware "Profile" selected. These "Profiles" are those ALSA "pcms" listed by the command {{ic|aplay -L}}, and more specifically by the command {{ic|pacmd list-cards}}, which will include a line "index:", a list beginning "profiles:", and a line "active profile: <...>" in the output, among other things.
:Use {{Pkg|pavucontrol}} to control PulseAudio volume if needed.
+
  
===OSS===
+
The "active profile" can be set with the command {{ic|pacmd set-card-profile INDEX PROFILE}}, with ''no'' comma separating INDEX and PROFILE, where INDEX is just the number on the line "index:" and a PROFILE name is everything shown from the beginning of any line under "profile:" to just ''before'' the colon and first space, as shown by the command {{ic|pacmd list-cards}}.  For instance, {{ic|pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo}}.
There are multiple ways of making OSS-only programs play to PulseAudio:
+
  
====ossp====
+
It may be easier to select a "Profile" with a graphical tool like {{ic|pavucontrol}}, under the "Configuration" tab, or KDE System Settings, "Multimedia/Audio and Video Settings", under the "Audio Hardware Setup" tab.  Each audio "Card", which are those devices listed by the command {{ic|aplay -l}}, or again by the command {{ic|pacmd list-cards}}, will have its own selectable "Profile".  When a "Profile" has been selected, the then available "sources" and "sinks" can be seen by using the commands {{ic|pacmd list-sources}} and {{ic|pacmd list-sinks}}. Note that the "index" of the available sources and sinks will change each time a card profile is changed.
Start {{Pkg|ossp}} with:
+
  rc.d start osspd
+
  
Afterwards, add it to DAEMONS in {{ic|rc.conf}}.
+
The selected "Profile" can be an issue for some applications, especially the Adobe Flash players, typically {{ic|/usr/lib/mozilla/plugins/libflashplayer.so}} and {{ic|/usr/lib/PepperFlash/libpepflashplayer.so}}.  Often, these Flash players will only work when one of the Stereo profiles is selected, and otherwise, will play video with no sound, or will simply "crash".  When all else fails, you might try selecting a different profile.
  
====padsp wrapper (part of PulseAudio)====
+
Of course, when configuring some variation of Surround Sound in PulseAudio, the appropriate Surround profile will have to be selected, before Surround Sound will work, or in order to do things like remap the speaker channels.
Programs using OSS can work with PulseAudio by starting it with padsp:
+
  
$ padsp OSSprogram
+
== Running ==
A few examples:
+
$ padsp aumix
+
$ padsp sox foo.wav -t ossdsp /dev/dsp
+
  
One can also rename the {{ic|OSSprogram-bin}} binary and replace it with a script like this:
+
Since [http://www.freedesktop.org/wiki/Software/PulseAudio/Notes/7.0/ version 7.0], PulseAudio on Arch uses socket activation. [https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/pulseaudio&id=419bd740dc8 By default], {{ic|pulseaudio.socket}} is enabled for the [[systemd/User]] instance.
{{hc|/usr/bin/OSSProgram|<nowiki>
+
#!/bin/sh
+
if test -x /usr/bin/padsp; then
+
    exec /usr/bin/padsp /usr/bin/OSSprogram-bin "$@"
+
else
+
    exec /usr/bin/OSSprogram "$@"
+
fi
+
</nowiki>}}
+
  
===GStreamer===
+
{{Note|
To make [[GStreamer]] use PulseAudio, you need to install {{Pkg|gstreamer0.10-good-plugins}}, execute {{ic|gstreamer-properties}} (part of ''gnome-media'' package) and select ''PulseAudio Sound Server'' in both Audio Input and Output. Alternatively, this can be done by setting the gconf variables {{ic|/system/gstreamer/0.10/default/audiosink}} to ''pulsesink'' and {{ic|/system/gstreamer/0.10/default/audiosrc}} to ''pulsesrc'':
+
* To disable {{ic|pulseaudio.socket}}, make sure that {{ic|$XDG_CONFIG_HOME/systemd/user/}} exists and run {{ic|systemctl --user mask pulseaudio.socket}}.
  $ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosink pulsesink
+
* Many [[desktop environments]] autostart programs based on [[Desktop entries#Autostart|desktop files]] in the {{ic|/etc/xdg/autostart/}} directory. In this case, PulseAudio will be launched automatically regardless of the socket activation status.
  $ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosrc pulsesrc
+
}}
  
Some applications (like Rhythmbox) ignore the ''audiosink'' property, but rely instead on ''musicaudiosink'', which cannot be configured using {{ic|gstreamer-properties}} but needs to be manually set using {{ic|gconf-editor}} or the {{ic|gconftool-2}}:
+
For more information, see [http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Running/ PulseAudio: Running].
  $ gconftool-2 -t string --set /system/gstreamer/0.10/default/musicaudiosink pulsesink
+
  
===OpenAL===
+
=== Starting manually ===
OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so: {{hc|/etc/openal/alsoft.conf|2=drivers=pulse,alsa}}
+
  
===libao===
+
PulseAudio can be manually started with:
Edit the libao configuration file:
+
$ pulseaudio --start
{{hc|/etc/libao.conf|2=default_driver=pulse}}
+
Be sure to remove the ''dev=default'' option of the alsa driver or adjust it to specify a specific Pulse sink name or number. Alternatively, note that you could keep the libao standard of outputting to the ''alsa'' driver and its default device if you install {{Pkg|pulseaudio-alsa}} since the ALSA default device then '''is''' PulseAudio.
+
+
===ESD===
+
PulseAudio is a drop-in replacement for the enlightened sound daemon (ESD). While PulseAudio is running, ESD clients should be able to output to it without configuration.
+
  
==Desktop Environments==
+
And stopped with:
===General X11===
+
$ pulseaudio --kill
{{Note|As mentioned previously, PulseAudio is very likely launched automatically via either {{ic|/etc/X11/xinit/xinitrc.d/pulseaudio}} or the files in {{ic|/etc/xdg/autostart/}} if users have some DE installed.}}
+
  
Check to see if PulseAudio is running:
+
== Back-end configuration ==
  
$ ps aux | grep pulse
+
=== ALSA ===
facade  1794  0.0  0.0 360464  6532 ?        S<l  15:33  0:00 /usr/bin/pulseaudio --start
+
facade  1827  0.0  0.0  68888  2608 ?        S    15:33  0:00 /usr/lib/pulse/gconf-helper
+
  
If Pulseaudio is not running and users are using X, the following will start PulseAudio with the needed the X11 plugins manually:
+
Install the {{Pkg|pulseaudio-alsa}} package. It contains the necessary {{ic|/etc/asound.conf}} for configuring ALSA to use PulseAudio. Also make sure that {{ic|~/.asoundrc}} does not exist, it would override the {{ic|/etc/asound.conf}} file.
$ start-pulseaudio-x11
+
  
If you are not running Gnome, KDE or XFCE and your {{ic|~/.xinitrc}} does not source the scripts in {{ic|/etc/X11/xinit/xinitrc.d}} (such as is done in the example file {{ic|/etc/skel/.xinitrc}}) then you can launch PulseAudio on boot by adding the following line to ~/.xinitrc:
+
Also install {{Pkg|lib32-libpulse}} and {{Pkg|lib32-alsa-plugins}} if you run a x86_64 system and want to have sound for 32-bit [[multilib]] programs like Wine, Skype and Steam.
/usr/bin/start-pulseaudio-x11
+
  
===GNOME===
+
To prevent applications from using ALSA's OSS emulation and bypassing PulseAudio (thereby preventing other applications from playing sound), make sure the module {{ic|snd_pcm_oss}} is not being loaded at boot. If it is currently loaded ({{ic|<nowiki>lsmod | grep oss</nowiki>}}), disable it by executing:
As of GNOME 3, GNOME fully integrates with PulseAudio and no extra configuration is needed.
+
# rmmod snd_pcm_oss
  
===KDE 3===
+
==== ALSA/dmix without grabbing hardware device ====
PulseAudio is ''not'' a drop-in replacement for aRts. Users of KDE 3 cannot use PulseAudio. However note, recent versions of PulseAudio may have eliminated the prohibition:
+
  
See: http://www.pulseaudio.org/wiki/PerfectSetup KDE 3 uses the artsd sound server by default. However, artsd itself can be configured to use an Esound backend. Edit kcmartsrc (either in /etc/kde or /usr/share/config for global configuration or .kde/share/config to configure only one user) like this:
+
{{Note|This section describes alternative configuration, which is generally '''not''' recommended.}}
  
[Arts]
+
You may want to use ALSA directly in most of your applications while still being able to use applications which require PulseAudio at the same time. The following steps allow you to make PulseAudio use dmix instead of grabbing ALSA hardware device.
Arguments=\s-F 10 -S 4096 -a esd -n -s 1 -m artsmessage -c drkonqi -l 3 -f
+
NetworkTransparent=true
+
SuspendTime=1
+
  
===KDE Plasma Workspaces and Qt4===
+
* Remove package {{Pkg|pulseaudio-alsa}}, which provides compatibility layer between ALSA applications and PulseAudio. After this your ALSA apps will use ALSA directly without being hooked by Pulse.
PulseAudio, it will be used by KDE/Qt4 applications. For more information see the [http://www.pulseaudio.org/wiki/KDE KDE page in the PulseAudio wiki].
+
  
PulseAudio support has been merged into KMix, the default KDE sound mixer.
+
* Edit {{ic|/etc/pulse/default.pa}}.
 +
:Find and uncomment lines which load back-end drivers. Add '''device''' parameters as follows. Then find and comment lines which load autodetect modules.
 +
load-module module-alsa-sink '''device=dmix'''
 +
load-module module-alsa-source '''device=dsnoop'''
 +
# load-module module-udev-detect
 +
# load-module module-detect
  
If the phonon-gstreamer backend is used for Phonon, GStreamer should also be [[PulseAudio#GStreamer|configured]] to use PulseAudio by installing {{Pkg|gstreamer0.10-good-plugins}}.
+
* ''Optional:'' If you use {{Pkg|kdemultimedia-kmix}} you may want to control ALSA volume instead of PulseAudio volume:
 +
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.kde4/env/kmix_disable_pulse.sh
 +
$ chmod +x ~/.kde4/env/kmix_disable_pulse.sh
  
One useful tidbit from that page is to add {{ic|load-module module-device-manager}} to {{ic|/etc/pulse/default.pa}}.
+
* Now, reboot your computer and try running ALSA and PulseAudio applications at the same time. They both should produce sound simultaneously.
 +
:Use {{Pkg|pavucontrol}} to control PulseAudio volume if needed.
  
Additionally, the {{AUR|kdeplasma-applets-veromix}} is available in the [[AUR]] as a KDE alternative to KMix or pavucontrol.
+
=== OSS ===
  
===Xfce===
+
There are multiple ways of making OSS-only programs output to PulseAudio:
Applications running under Xfce can take advantage of PulseAudio. To manage PulseAudio settings you can use {{Pkg|pavucontrol}}.
+
  
==Applications==
+
==== ossp ====
===Audacious===
+
[[Audacious]] natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.
+
  
===Java/OpenJDK 6===
+
Install {{Pkg|ossp}} package and start {{ic|osspd.service}}.
Create a wrapper for the java executable using padsp as seen on the [[Java#Java_sound_with_Pulseaudio|Java sound with Pulseaudio]] page.
+
  
===Music Player Daemon (MPD)===
+
==== padsp wrapper ====
[http://mpd.wikia.com/wiki/PulseAudio configure] [[MPD]] to use PulseAudio. See also [[MPD/Tips_and_Tricks#MPD_.26_PulseAudio]].
+
  
===MPlayer===
+
Programs using OSS can work with PulseAudio by starting it with padsp (included with PulseAudio):
[[MPlayer]] natively supports PulseAudio output with the "{{ic|-ao pulse}}" option. It can also be configured to default to PulseAudio output, in {{ic|~/.mplayer/config}} for per-user, or {{ic|/etc/mplayer/mplayer.conf}} for system-wide:
+
{{hc|/etc/mplayer/mplayer.conf|2=ao=pulse}}
+
  
===Skype (x86_64 only)===
+
$ padsp OSSprogram
Install {{Pkg|lib32-libpulse}}, otherwise the following error will occur when trying to initiate a call: "Problem with Audio Playback".
+
  
==Troubleshooting==
+
A few examples:
===No sound after install===
+
  
====Muted audio device====
+
  $ padsp aumix
If one experiences no audio output via any means while using ALSA, attempt to unmute the sound card. To do this, launch alsamixer and make sure each column has a green 00 under it (this can be toggled by pressing 'm')
+
  $ padsp sox foo.wav -t ossdsp /dev/dsp
  $ alsamixer -c 0
+
  
====Bad configuration files====
+
You can also add a custom wrapper script like this: 
If after starting pulseaudio, the system outputs no sound, it may be necessary to delete the contents of {{ic|~/.pulse}}. Pulseaudio will automatically create new configuration files on its next start.
+
  
====Flash Content====
+
{{hc|/usr/local/bin/OSSProgram|<nowiki>
Since Adobe Flash does not directly support PulseAudio the recommended way is to [https://wiki.archlinux.org/index.php/PulseAudio#ALSA configure ALSA to use the virtual PulseAudio soundcard].
+
#!/bin/sh
 +
exec padsp /usr/bin/OSSprogram "$@"
 +
</nowiki>}}
  
Alternatively you may try out {{AUR|libflashsupport-pulse}} from the [[AUR]].
+
Make sure {{ic|/usr/local/bin}} comes before {{ic|/usr/bin}} in your '''PATH'''.
{{Note|This may invariably crash the flash plugin.}}
+
  
====No cards====
+
=== GStreamer ===
If PulseAudio starts, run {{ic|pacmd list}}. If no cards are reported, make sure that the ALSA devices are not in use:
+
$ fuser -v /dev/snd/*
+
$ fuser -v /dev/dsp
+
  
Make sure any applications using the pcm or dsp files are shut down before restarting PulseAudio.
+
Install {{Pkg|gst-plugins-good}}, or {{Pkg|gstreamer0.10-good-plugins}} if your intended program has a legacy [[GStreamer]] implementation.
  
====The only device shown is "dummy output"====
+
=== OpenAL ===
This may be caused by different reasons, one of them being the .asoundrc file in $HOME is taking precedence over the systemwide /etc/asound.conf.
+
  
The user file is modified also by the tool '''asoundconf''' or by its graphical variant '''asoundconf-gtk''' (the latter is named "Default sound card" in the menu) as soon as it  runs. Prevent the effects of .asoundrc altogether by commenting the last line like this:
+
OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so: {{hc|/etc/openal/alsoft.conf|2=drivers=pulse,alsa}}
  
#</home/<yourusername>/.asoundrc.asoundconf>
+
=== libao ===
  
 +
Edit the libao configuration file:
 +
{{hc|/etc/libao.conf|2=default_driver=pulse}}
 +
Be sure to remove the {{ic|1=dev=default}} option of the alsa driver or adjust it to specify a specific Pulse sink name or number.
  
Maybe some program is monopolizing the audio device. Try this command:
+
{{Note|You could possibly also keep the libao standard of outputting to the ''alsa'' driver and its default device if you install {{pkg|pulseaudio-alsa}} since the ALSA default device then '''is''' PulseAudio.}}
# fuser -v /dev/snd/*
+
  
If the output looks like this:
+
== Equalizer ==
                      UTIL.      PID ACCÈS  COMMANDE
+
/dev/snd/controlC0:  root        931 F.... timidity
+
                      bob        1195 F.... panel-6-mixer
+
/dev/snd/controlC1:  bob        1195 F.... panel-6-mixer
+
                      bob        1215 F.... pulseaudio
+
/dev/snd/pcmC0D0p:  root        931 F...m timidity
+
/dev/snd/seq:        root        931 F.... timidity
+
/dev/snd/timer:      root        931 f.... timidity
+
Then it means timidity blocks pulseaudio from accessing the audio devices. Just killing timidity will make the sound work again.
+
  
[to be improved and completed]
+
{{Warning|The equalizer module is considered unstable and might be removed from PulseAudio. For more, see the [https://lists.freedesktop.org/archives/pulseaudio-discuss/2014-March/020174.html mailing list].}}
  
 +
PulseAudio has an integrated 10-band equalizer system. In order to use the equalizer do the following:
  
Another reason is [[FluidSynth]] conclicting with pulseaudio as discussed in [https://bbs.archlinux.org/viewtopic.php?id=154002 this thread]. The solution is to remove FluidSynth:
+
Install {{Pkg|pulseaudio-equalizer}}:
  
# pacman -Rnsc fluidsynth
+
=== Load equalizer sink and dbus-protocol module ===
  
====KDE4====
+
$ pactl load-module module-equalizer-sink
It may be that another output device set as preferred in phonon. Make sure that every setting reflects the preferred output device at the top, and check the playback streams tab in kmix to make sure that applications are using the device for output.
+
$ pactl load-module module-dbus-protocol
  
====Failed to create sink input: sink is suspended====
+
=== GUI front-end ===
If you do not have any output sound and receive dozens of errors related to a suspended sink in your '''journalctl -b''' log, then backup first and then delete your user-specific pulse folders:
+
  
$ rm -r ~/.pulse ~/.pulse-cookie
+
run:
  
===Bluetooth headset replay problems===
+
$ qpaeq
Some user [https://bbs.archlinux.org/viewtopic.php?id=117420 report] huge delays or even no sound when the bluetooth connection does not send any data. This is due to an idle-suspend-module that puts the related sinks/sources automatically into suspend. As this can cause problems with headset, the responsible module can be deactivated.
+
  
1. cp /etc/pulse/default.pa ~/.pulse/default.pa
+
{{Note|If qpaeq has no effect, install {{pkg|pavucontrol}} and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.}}
2. comment out the "load-module module-suspend-on-idle" line in ~/.pulse/default.pa
+
3. pulseaudio -k && pulseaudio --start
+
  
[http://robert.orzanna.de/2011/08/prevent-idle-suspend-with-bluetooth.html More information]
+
=== Load equalizer and dbus module on every boot ===
  
===Automatically switch to Bluetooth or USB headset===
+
Edit the {{ic|/etc/pulse/default.pa}} or {{ic|~/.config/pulse/default.pa}} file with your favorite editor and append the following lines:
Add the following to your /etc/pulse/default.pa:
+
  
  # automatically switch to newly-connected devices
+
  ### Load the integrated PulseAudio equalizer and D-Bus module
  load-module module-switch-on-connect
+
  load-module module-equalizer-sink
 +
load-module module-dbus-protocol
  
===Pulse overwrites ALSA settings===
+
{{Note|The equalizer sink needs to be loaded after the master sink is already available.}}
Pulseaudio usually overwrites the ALSA settings- for example set with alsamixer- at start up, even when the alsa daemon is loaded. Since there seems to be no other way to restrict this behaviour, a workaround is to restore the alsa settings again after pulseaudio had started. Add the following command to {{ic|.xinitrc}} {{ic|.bash_login}} or any other autostart file:
+
  
restore_alsa() {
+
== Applications ==
  while [ -z "`pidof pulseaudio`" ]; do
+
  sleep 0.5
+
  done
+
  alsactl -f /var/lib/alsa/asound.state restore
+
}
+
restore_alsa &
+
  
===Prevent Pulse from restarting after being killed===
+
=== QEMU ===
Sometimes you may wish to temporarily disable Pulse. In order to do so you will have to prevent Pulse from restarting after being killed.
+
  
$ echo autospawn=no > ~/.pulse/client.conf
+
{{Merge|QEMU|QEMU is the most complex of the "applications" described in this section, merging to the main article would provide better context.}}
  
===Daemon startup failed===
+
The audio driver used by QEMU is set with the {{ic|QEMU_AUDIO_DRV}} environment variable:
Try resetting PulseAudio. To do that:
+
$ pulseaudio --kill
+
$ killall pulseaudio
+
$ killall -9 pulseaudio
+
$ rm -rf ~/.pulse*
+
$ rm -rf /tmp/pulse*
+
  
Afterwards, start PulseAudio again.
+
$ export QEMU_AUDIO_DRV=pa
  
If there is no server running but pulseaudio fails to start with an error message "User-configured server at ... refusing to start/autospawn", the issue may be with PulseAudio settings from a previous login. Check to see if there are any stale properties attached to the X11 root window with {{ic|pax11publish -d}}, and if there are, remove them with {{ic|pax11publish -r}} before trying to start the server. This manual cleanup is always required when using LXDM because it does not restart the X server on logout; see [[LXDM#PulseAudio]].
+
Run the following command to get QEMU's configuration options related to PulseAudio:
  
===padevchooser===
+
  $ qemu-system-x86_64 -audio-help | awk '/Name: pa/' RS=
If one cannot launch the PulseAudio Device Chooser, first (re)start the Avahi daemon as follows:
+
  $ rc.d restart avahi-daemon
+
  
===Glitches, skips or crackling===
+
The listed options can be exported as environment variables, for example:
The newer implementation of PulseAudio sound server uses a timer-based audio scheduling instead of the traditional interrupt-driven approach.
+
  
Timer-based scheduling may expose issues in some ALSA drivers. On the other hand, other drivers might be glitchy without it on, so check to see what works on your system.  
+
{{bc|1=
 +
$ export QEMU_PA_SINK=alsa_output.pci-0000_04_01.0.analog-stereo.monitor
 +
$ export QEMU_PA_SOURCE=input
 +
}}
  
To turn timer-based scheduling off, replace the line:
+
{{Style|The following is not specific to PulseAudio.}}
load-module module-udev-detect
+
in {{ic|/etc/pulse/default.pa}} by:
+
load-module module-udev-detect tsched=0
+
Then restart the PulseAudio server.
+
  
Do the reverse to enable timer-based scheduling, if not already enabled by default.
+
To get list of the supported emulation audio drivers
 +
$ qemu-system-x86_64 -soundhw help
  
Please report any such cards to [http://pulseaudio.org/wiki/BrokenSoundDrivers PulseAudio Broken Sound Driver page]
+
To use e.g. {{ic|ac97}} driver for the guest use the {{ic|-soundhw ac97}} commnad with QEMU.
  
===Setting the default fragment number and buffer size in Pulseaudio===
+
{{Note|Video graphic card emulated drivers for the guest machine may also cause a problem with the sound quality. Test one by one to make it work. You can list possible options with {{ic|<nowiki>qemu-system-x86_64 -h | grep vga</nowiki>}}.}}
+
1. Finding out your audio device parameters
+
  
Run the following Bash commands to find your sound card buffering settings:
+
=== AlsaMixer.app ===
echo autospawn = no >> ~/.pulse/client.conf
+
killall pulseaudio
+
LANG=C timeout --foreground -k 10 -s kill 10 pulseaudio -vvvv 2>&1 | grep device.buffering -B 10
+
sed -i '$d' ~/.pulse/client.conf
+
  
For each sound card detected by Pulseaudio, you will see output similar to this:
+
Make {{AUR|alsamixer.app}} dockapp for the {{Pkg|windowmaker}} use pulseaudio, e.g.
I: [pulseaudio] source.c:    alsa.long_card_name = "HDA Intel at 0xfa200000 irq 46"
+
  $ AlsaMixer.app --device pulse
I: [pulseaudio] source.c:    alsa.driver_name = "snd_hda_intel"
+
  I: [pulseaudio] source.c:    device.bus_path = "pci-0000:00:1b.0"
+
I: [pulseaudio] source.c:    sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
+
I: [pulseaudio] source.c:    device.bus = "pci"
+
I: [pulseaudio] source.c:    device.vendor.id = "8086"
+
I: [pulseaudio] source.c:    device.vendor.name = "Intel Corporation"
+
I: [pulseaudio] source.c:    device.product.name = "82801I (ICH9 Family) HD Audio Controller"
+
I: [pulseaudio] source.c:    device.form_factor = "internal"
+
I: [pulseaudio] source.c:    device.string = "front:0"
+
I: [pulseaudio] source.c:    device.buffering.buffer_size = "768000"
+
I: [pulseaudio] source.c:    device.buffering.fragment_size = "384000"
+
  
Take note the buffer_size and fragment_size values for the relevant sound card.
+
Here is a two examples where the first one is for ALSA and the other one is for pulseaudio. You can run multiple instances of it. Use the {{ic|-w}} option to choose which of the control buttons to bind to the mouse wheel.
 +
# AlsaMixer.app -3 Mic -1 Master -2 PCM --card 0 -w 1
 +
# AlsaMixer.app --device pulse -1 Capture -2 Master -w 2
  
2. Calculate your fragment size in msecs and number of fragments
+
{{Note|It can use only those output sinks that set as default.}}
  
Pulseaudio's default sampling rate and bit depth are set to 44100Hz @ 16 bits.
+
=== XMMS2 ===
  
With this configuration, the bit rate we need is 44100*16 = 705600 bits per second. That's 1411200 bps for stereo.
+
Make it switch to pulseaudio output
 +
$ nyxmms2 server config output.plugin pulse
 +
and to alsa
 +
$ nyxmms2 server config output.plugin alsa
 +
To make xmms2 use a different output sink, e.g.
 +
  $ nyxmms2 server config pulse.sink alsa_output.pci-0000_04_01.0.analog-stereo.monitor
  
Let's take a look at the parameters we've found in the previous step:
+
See also the official guide [https://xmms2.org/wiki/Using_the_application].
  
device.buffering.buffer_size = "768000" => 768000/1411200 = 0.544217687075s = 544 msecs
+
=== KDE Plasma Workspaces and Qt4 ===
device.buffering.fragment_size = "384000" => 384000/1411200 = 0.272108843537s = 272 msecs
+
  
3.Modify Pulseaudio's configuration file
+
PulseAudio will automatically be used by KDE/Qt4 applications. It is supported by default in the KDE sound mixer. For more information see the [http://www.pulseaudio.org/wiki/KDE KDE page in the PulseAudio wiki]. One useful tidbit from that page is to add {{ic|load-module module-device-manager}} to {{ic|/etc/pulse/default.pa}}.
  
Edit the configuration file located at {{ic|/etc/pulse/daemon.conf}} using the editor of your choice.
+
If the phonon-gstreamer backend is used for Phonon, GStreamer should also be configured as described in [[#GStreamer]].
  
For example:
+
=== Audacious ===
sudo vi /etc/pulse/daemon.conf
+
  
Locate & uncomment (remove leading semicolons) these lines:
+
[[Audacious]] natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.
  
; default-fragments = X
+
=== Java/OpenJDK 6 ===
; default-fragment-size-msec = Y
+
  
 +
Create a wrapper for the Java executable using padsp as seen on the [[Java#Java_sound_with_PulseAudio|Java sound with PulseAudio]] page.
  
In the previous step, we calculated the fragment size parameter.
+
=== Music Player Daemon (MPD) ===
The number of fragments is simply buffer_size/fragment_size, which in this case (544/272) is 2.
+
  
Edit the lines to use your calculated settings:
+
[http://mpd.wikia.com/wiki/PulseAudio configure] [[MPD]] to use PulseAudio. See also [[MPD/Tips and Tricks#MPD and PulseAudio]].
  
default-fragment-size-msec = 272
+
=== MPlayer ===
default-fragments = 2
+
  
Save the file.
+
[[MPlayer]] natively supports PulseAudio output with the {{ic|-ao pulse}} option. It can also be configured to default to PulseAudio output, in {{ic|~/.mplayer/config}} for per-user, or {{ic|/etc/mplayer/mplayer.conf}} for system-wide:
 +
{{hc|/etc/mplayer/mplayer.conf|2=ao=pulse}}
  
 +
=== guvcview ===
  
4.Restart the Pulseaudio daemon
+
{{Pkg|guvcview}} when using the PulseAudio input from a [[Webcam]] may have the audio input suspended resulting in no audio being recorded.  You can check this by executing:
  
  pulseaudio -k
+
  $ pactl list sources
pulseaudio --start
+
  
Source: [http://forums.linuxmint.com/viewtopic.php?f=42&t=44862 kwevej @ Linux Mint Forums]
+
If the audio source is "suspended" then modifying the following line in {{ic|/etc/pulse/default.pa}} and changing:
  
===Laggy sound===
+
load-module module-suspend-on-idle
This issue is due to incorrect buffer sizes.
+
to
Edit {{ic|/etc/pulse/daemon.conf}}
+
#load-module module-suspend-on-idle
  
Either disable any modifications (if any) to these entries, or, if issue still exists, uncomment and change them in the following way:
+
And then either restarting PulseAudio or your computer will only idle the input source instead of suspending it. guvcview will then correctly record audio from the device.
  default-fragments = 8
+
default-fragment-size-msec = 5
+
  
===Choppy, overdriven sound===
+
== Tips and tricks ==
Choppy sound in pulsaudio can result from wrong settings for the sample rate in {{Ic|/etc/pulse/daemon.conf}}. Try changing the line
+
; default-sample-rate = 44100
+
to
+
default-sample-rate = 48000
+
and restart the PulseAudio server.
+
  
If one experiences choppy sound in applications using openAL, change the sample rate in /etc/openal/alsoft.conf:
+
=== Keyboard volume control ===
frequency = 48000
+
  
Setting the PCM volume above 0dB can cause clipping of the audio signal.  Running {{ic|alsamixer -c0}} will allow you to see if this is the problem and if so fix it.
+
Map the following commands to your volume keys: {{ic|XF86AudioRaiseVolume}}, {{ic|XF86AudioLowerVolume}}, {{ic|XF86AudioMute}}
  
===Volume adjustment does not work properly===
+
First find out which sink corresponds to the audio output you'd like to control.
Check:
+
To list available sinks:
{{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common}}
+
pactl list sinks short
  
If the volume does not appear to increment/decrement properly using {{ic|alsamixer}} or {{ic|amixer}}, it may be due to pulseaudio having a larger number of increments (65537 to be exact). Try using larger values when changing volume (e.g. {{ic|amixer set Master 655+}}).
+
Suppose sink 0 is to be used, to raise the volume:
 +
sh -c "pactl set-sink-mute 0 false ; pactl set-sink-volume 0 +5%"
  
===Volume gets louder every time a new application is started===
+
To lower the volume:
Per default, it seems as if changing the volume in an application sets the global system volume to that level instead of only affecting the respective application. Applications setting their volume on startup will therefore cause the system volume to "jump".
+
sh -c "pactl set-sink-mute 0 false ; pactl -- set-sink-volume 0 -5%"
  
Fix this by uncommenting the line
+
To mute/unmute the volume:
flat-volumes = yes
+
  pactl set-sink-mute 0 toggle
and changing it to:
+
  flat-volumes = no
+
in
+
/etc/pulse/daemon.conf
+
and then restarting PulseAudio by executing
+
pulseaudio --kill && pulseaudio --start
+
  
When Pulse comes back after a few seconds, applications will not alter the global system volume anymore but have their own volume level again.
+
To mute/unmute the microphone:
 +
pactl set-source-mute 1 toggle
  
{{Note|A previously installed and removed pulseaudio-equalizer may leave behind remnants of the setup in {{Ic|$HOME/.pulse/default.pa}} which can also cause maximized volume trouble. Comment that out as needed.}}
+
=== Play sound from a non-interactive shell (systemd service, cron) ===
  
===No mic on ThinkPad T400/T500/T420===
+
Set {{ic|XDG_RUNTIME_DIR}} before the command (replace {{ic|''user_id''}} with the ID of the user running PulseAudio):
Run
+
alsamixer -c 0
+
Maximize the volume of/unmute the "Internal Mic".
+
  
Once you see the device with
+
  XDG_RUNTIME_DIR=/run/user/''user_id'' paplay /usr/share/sounds/freedesktop/stereo/complete.oga
  arecord -l
+
you might still need to adjust the settings. The microphone and the audio jack are duplexed. Set the configuration of the internal audio in pavucontrol to ''Analog Stereo Duplex''.
+
  
===No mic input on Acer Aspire One===
+
Or use {{ic|machinectl}}:
Install pavucontrol, unlink the microphone channels and turn down the left one to 0.
+
Reference: http://getsatisfaction.com/jolicloud/topics/deaf_internal_mic_on_acer_aspire_one#reply_2108048
+
  
===Sound output is only mono on M-Audio Audiophile 2496 sound card===
+
# machinectl shell .host --uid=''user_id'' /usr/bin/paplay /usr/share/sounds/freedesktop/stereo/complete.oga
Add the following to /etc/pulseaudio/default.pa:
+
load-module module-alsa-sink sink_name=delta_out device=hw:M2496 format=s24le channels=10 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7
+
load-module module-alsa-source source_name=delta_in device=hw:M2496 format=s24le channels=12 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9
+
set-default-sink delta_out
+
set-default-source delta_in
+
  
===Static Noise in Microphone Recording===
+
=== X11 Bell Events ===
If we are getting static noise in skype, gnome-sound-recorder, arecord, etc.'s recordings then the sound card samplerate is incorrect. That is why there is static noise in linux microphone recordings. To fix this We need to set sample-rate in /etc/pulse/daemon.conf for the sound hardware.
+
  
====1. Determine soundcards in the system====
+
To get pulseaudio to handle X11 bell events, run the following commands after the X11 session has been started:
This requires alsa-utils and related packages to be installed:
+
$  arecord --list-devices
+
  
output:
+
pactl upload-sample /usr/share/sounds/freedesktop/stereo/bell.oga x11-bell
    **** List of CAPTURE Hardware Devices ****
+
pactl load-module module-x11-bell sample=x11-bell display=$DISPLAY
    card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]
+
      Subdevices: 1/1
+
      Subdevice #0: subdevice #0
+
    card 0: Intel [HDA Intel], device 2: ALC888 Analog [ALC888 Analog]
+
      Subdevices: 1/1
+
      Subdevice #0: subdevice #0
+
  
soundcard is hw:0,0
+
To adjust the volume of the X11 bell, run the following command:
  
====2. Determine sampling-rate of the sound card====
+
  xset b 100
  arecord -f dat -r 60000 -D hw:0,0 -d 5 test.wav
+
  
output:
+
100 is a percentage. This requires the {{Pkg|xorg-xset}} package. See [[Autostarting]] for a way to run these commands automatically when the X11 session is started.
  "Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo
+
  Warning: rate is not accurate (requested = 60000Hz, '''got = 96000Hz''')
+
  please, try the plug plugin
+
  
observe, the '''got = 96000Hz''', this is the max sample-rate of our card.
+
=== Switch on connect ===
 +
This is a module used to switch the output sound to the newly connected device. For example, if you plug in a USB headset, the output will be switched to that. If you unplug it, the output will be set back to the last device. This used to be quite buggy but got a lot of attention in PulseAudio 8.0 and should work quite well now.
  
====3. Setting the soundcard's sampling rate into pulse audio configuration====
+
If you just want to test the module then you can load it at runtime by calling:
the default sample-rate in pulseaudio is
+
  # pactl load-module module-switch-on-connect
  grep "sample-rate" /etc/pulse/daemon.conf
+
  
output:
+
If you want to make the change persistent you will have to add it to your local pulseaudio settings or to /etc/pulse/default.pa (system wide effect). In either case, add this line:
    ; default-sample-rate = 44100
+
load-module module-switch-on-connect
  
It is 44100 and is disabled. Let us set our sound card's settings into pulseaudio configuation file
+
{{Accuracy|Editing {{ic|/usr/bin/start-pulseaudio-x11}} will not survive package upgrade. The offending module can be unloaded in the config before loading {{ic|module-switch-on-connect}}, see [[Talk:Bluetooth_headset#GDMs_pulseaudio_instance_captures_bluetooth_headset]].}}
su -c "sed 's/; default-sample-rate = 44100/default-sample-rate = 96000/g' -i /etc/pulse/daemon.conf"
+
  
Let us verify the changes to deamon.conf
+
On KDE/Plasma5 you should furthermore disable module-device-manager. As soon as Plasma5 is started it loads (via start-pulseaudio-x11) the module module-device-manager for pulseaudio to manage the devices. But that module apparently conflicts with module-switch-on-connect. Therefore you should disable that module by editing /bin/start-pulseaudio-x11 and commenting the lines for KDE. Simply logout and login again and in order to renew your pulseaudio session. On connect switching should now work properly.
grep "sample-rate" /etc/pulse/daemon.conf
+
output:
+
  default-sample-rate = 96000
+
and it is done.
+
  
====4. Restart pulseaudio to apply the new settings====
+
== Troubleshooting ==
pulseaudio --kill
+
pulseaudio --start
+
  
====5. Finally check by recording and playing it back====
+
See [[PulseAudio/Troubleshooting]].
Let us record some voice using mic for say 10 seconds. Make sure the mic is not muted and all
+
arecord -f cd -d 10 test-mic.wav
+
 
+
After 10 seconds, let us play the recording...
+
aplay test-mic.wav
+
 
+
Now hopefully, there is no static noise in microphone recording anymore.
+
 
+
=== My Bluetooth device is paired but does not play any sound ===
+
[[Bluetooth#My_device_is_paired_but_no_sound_is_played_from_it|See the article in Bluetooth section]]
+
 
+
Starting from PulseAudio 2.99 and bluez 4.101 you should '''avoid''' using Socket interface. Do NOT add
+
[General]
+
Enable=Socket
+
to your /etc/bluetooth/audio.conf.
+
If you face problems with A2DP and PA 2.99 make sure you have SBC library:
+
pacman -S sbc
+
 
+
=== Subwoofer stops working after end of every song  ===
+
Known issue: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/494099
+
 
+
To fix this, must edit: {{ic|/etc/pulse/daemon.conf}} and enable {{ic|enable-lfe-remixing}} :
+
{{hc|/etc/pulse/daemon.conf|<nowiki>
+
enable-lfe-remixing = yes
+
</nowiki>}}
+
 
+
=== Pulseaudio uses wrong microphone ===
+
If Pulseaudio uses the wrong microphone, and changing the Input Device with Pavucontrol did not help, take a look at alsamixer. It seems that Pavucontrol does not always set the input source correctly.<br>
+
Run:
+
 
+
$ alsamixer
+
 
+
press F6 and choose your sound card, e.g. HDA Intel. Now press F5 to display all items. Try to find the item: {{ic|Input Source}}. With the up/down arrow keys you are able to change the input source. <br>
+
Now try if the correct microphone is used for recording.
+
 
+
=== Choppy Sound with Analog Surround Sound Setup ===
+
 
+
The low-frequency effects (LFE) channel is not remixed per default. To enable it the following needs to be set in {{ic|/etc/pulse/daemon.conf}} :
+
{{hc|/etc/pulse/daemon.conf|<nowiki>
+
enable-lfe-remixing = yes
+
</nowiki>}}
+
 
+
=== No sound below a volume cutoff ===
+
Known issue (won't fix): https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/223133
+
 
+
If sound doesn't play when Pulseaudio's volume is set below a certain level, try editing {{ic|/etc/pulse/default.pa}} and changing:
+
{{hc|/etc/pulse/default.pa|<nowiki>
+
load-module module-udev-detect
+
</nowiki>}}
+
to
+
{{hc|/etc/pulse/default.pa|<nowiki>
+
load-module module-udev-detect ignore_dB=1
+
</nowiki>}}
+
  
=== Low volume for internal mic ===
+
== See also ==
If you experience low volume on internal notebook microphone, try setting
+
{{hc|/etc/pulse/default.pa|<nowiki>
+
set-source-volume 1 300000
+
</nowiki>}} at the end of the file.
+
  
==External links==
+
* [http://www.alsa-project.org/main/index.php/Asoundrc .asoundrc on ALSA wiki]
*[http://www.pulseaudio.org/wiki/PerfectSetup http://www.pulseaudio.org/wiki/PerfectSetup] - A good guide to make your configuration perfect
+
* [http://www.pulseaudio.org/ PulseAudio official site]
*[http://www.alsa-project.org/main/index.php/Asoundrc http://www.alsa-project.org/main/index.php/Asoundrc] - Alsa wiki on .asoundrc
+
* [http://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/ PulseAudio FAQ]
*[http://www.pulseaudio.org/ http://www.pulseaudio.org/] - PulseAudio official site
+
*[http://www.pulseaudio.org/wiki/FAQ http://www.pulseaudio.org/wiki/FAQ] - PulseAudio FAQ
+

Latest revision as of 08:17, 3 April 2016

PulseAudio serves as a proxy to sound applications using existing kernel sound components like ALSA or OSS. Since ALSA is included in Arch Linux by default, the most common deployment scenarios include PulseAudio with ALSA.

Installation

Install the pulseaudio package.

Some PulseAudio modules have been split from the main package and must be installed separately if needed:

Note: Some confusion can be made between ALSA and PulseAudio. ALSA includes both Linux kernel component with sound card drivers, and a userspace component, libalsa.[1] PulseAudio builds only on the kernel component, but offers compatibility with libalsa through pulseaudio-alsa.[2]

Front-ends

There is a number of front-ends available for controlling the PulseAudio daemon:

Configuration

Configuration files

Merge-arrows-2.pngThis article or section is a candidate for merging with PulseAudio/Configuration.Merge-arrows-2.png

Notes: Configuration should stay in the main article, so the linked page should be merged here. Split #Troubleshooting instead if this page is found too long. (Discuss in Talk:PulseAudio#Abandoned draft)

By default, PulseAudio is configured to automatically detect all sound cards and manage them. It takes control of all detected ALSA devices and redirect all audio streams to itself, making the PulseAudio daemon the central configuration point. The daemon should work mostly out of the box, only requiring a few minor tweaks.

PulseAudio will first look for configuration files in home directory ~/.config/pulse, then in system wide /etc/pulse.

PulseAudio runs as a server daemon that can run either system-wide or on per-user basis using a client/server architecture. The daemon by itself does nothing without its modules except to provide an API and host dynamically loaded modules. The audio routing and processing tasks are all handled by various modules. You can find a detailed list of all available modules at Pulseaudio Loadable Modules. To enable them you can just add a line load-module <module-name-from-list> to ~/.config/pulse/default.pa.

Tip:
  • It is strongly suggested not to edit system wide configuration files, but rather edit user ones. Create the ~/.config/pulse directory, then copy the system configuration files into it and edit according to your need.
  • Make sure you keep user configuration in sync with changes to the packaged files in /etc/pulse/. Otherwise, PulseAudio may refuse to start due to configuration errors.
  • There is usually no need to add your user to the audio group, as PulseAudio uses udev and logind to give access dynamically to the currently "active" user. Exceptions would include running the machine headless so that there is no currently "active" user.

daemon.conf

Defines base settings like the default sample rates used by modules, resampling methods, realtime scheduling and various other settings related to the server process. These can not be changed at runtime without restarting the PulseAudio daemon. The defaults are sensible for most users.

Note: PulseAudio does not perform tilde expansion on paths in this file. Use absolute paths for any files.
Notable configuration options
Option Description
system-instance Run the daemon as a system-wide instance. Highly discouraged as it can introduce security issues. Useful on (headless) systems that have no real local users. Defaults to no.
resample-method Which resampler to use when audio with incompatible sample rates needs to be passed between modules (e.g. playback of 96kHz audio on hardware which only supports 48kHz). The available resamplers can be listed with $ pulseaudio --dump-resample-methods. Choose the best tradeoff between CPU usage and audio quality for the present use-case.
Tip: In some cases PulseAudio will generate a high CPU load. This can happen when multiple streams are resampled (individually). If this is a common use-case in a workflow, it should be considered to create an additional sink at a matching sample rate which can then be fed into the main sink, resampling only once.
flat-volumes flat-volumes scales the device-volume with the volume of the "loudest" application. For example, raising the VoIP call volume will raise the hardware volume and adjust the music-player volume so it stays where it was, without having to lower the volume of the music-player manually. Defaults to yes upstream, but to no within Arch.
Note: The default behavior upstream can sometimes be confusing and some applications, unaware of this feature, can set their volume to 100% at startup, potentially blowing your speakers or your ears. This is why Arch defaults to the classic (ALSA) behavior by setting this to no.
default-fragments Audio samples are split into multiple fragments of default-fragment-size-msec each. The larger the buffer is, the less likely audio will skip when the system is overloaded. On the downside this will increase the overall latency. Increase this value if you have issues.

default.pa

This file is a startup script and is used to configure modules. It is actually parsed and read after the daemon has finished initializing and additional commands can be sent at runtime using $ pactl or $ pacmd. The startup script can also be provided on the command line by starting PulseAudio in a terminal using $ pulseaudio -nC. This will make the daemon load the CLI module and will accept the configuration directly from the command line, and output resulting information or error messages on the same terminal. This can be useful when debugging the daemon or just to test various modules before setting them permanently on disk. The manual page is quite self-explanatory, consult man pulse-cli-syntax for the details of the syntax.

Tip:
  • Rather than being a complete copy, ~/.config/pulse/default.pa can start with the line .include /etc/pulse/default.pa and then just override the defaults.
  • Run $ pacmd list-sinks|egrep -i 'index:|name:' to list available sinks. The present default sink is marked with an asterisk.
  • Edit ~/.config/pulse/default.pa to insert/alter the set-default-sink command using the sink's name as the numbering cannot be guaranteed repeatable.

client.conf

This is the configuration file read by every PulseAudio client application. It is used to configure runtime options for individual clients. It can be used to set and configure the default sink and source statically as well as allowing (or disallowing) clients to automatically start the server if not currently running.

Configuration command

The main command to configure a server during runtime is $ pacmd. Run $ pacmd --help for a list options, or just run $ pacmd to enter the shell interactive mode and Ctrl+d to exit. All modifications will immediately be applied.

Once your new settings have been tested and meet your needs, edit the default.pa accordingly to make the change persistent. See PulseAudio/Examples for some basic settings.

Tip: leave the load-module module-default-device-restore line in the default.pa file untouched. It will allow you to restart the server in its default state, thus dismissing any wrong setting.

It is important to understand that the "sources" (processes, capture devices) and "sinks" (sound cards, servers, other processes) accessible and selectable through PulseAudio depend upon the current hardware "Profile" selected. These "Profiles" are those ALSA "pcms" listed by the command aplay -L, and more specifically by the command pacmd list-cards, which will include a line "index:", a list beginning "profiles:", and a line "active profile: <...>" in the output, among other things.

The "active profile" can be set with the command pacmd set-card-profile INDEX PROFILE, with no comma separating INDEX and PROFILE, where INDEX is just the number on the line "index:" and a PROFILE name is everything shown from the beginning of any line under "profile:" to just before the colon and first space, as shown by the command pacmd list-cards. For instance, pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo.

It may be easier to select a "Profile" with a graphical tool like pavucontrol, under the "Configuration" tab, or KDE System Settings, "Multimedia/Audio and Video Settings", under the "Audio Hardware Setup" tab. Each audio "Card", which are those devices listed by the command aplay -l, or again by the command pacmd list-cards, will have its own selectable "Profile". When a "Profile" has been selected, the then available "sources" and "sinks" can be seen by using the commands pacmd list-sources and pacmd list-sinks. Note that the "index" of the available sources and sinks will change each time a card profile is changed.

The selected "Profile" can be an issue for some applications, especially the Adobe Flash players, typically /usr/lib/mozilla/plugins/libflashplayer.so and /usr/lib/PepperFlash/libpepflashplayer.so. Often, these Flash players will only work when one of the Stereo profiles is selected, and otherwise, will play video with no sound, or will simply "crash". When all else fails, you might try selecting a different profile.

Of course, when configuring some variation of Surround Sound in PulseAudio, the appropriate Surround profile will have to be selected, before Surround Sound will work, or in order to do things like remap the speaker channels.

Running

Since version 7.0, PulseAudio on Arch uses socket activation. By default, pulseaudio.socket is enabled for the systemd/User instance.

Note:
  • To disable pulseaudio.socket, make sure that $XDG_CONFIG_HOME/systemd/user/ exists and run systemctl --user mask pulseaudio.socket.
  • Many desktop environments autostart programs based on desktop files in the /etc/xdg/autostart/ directory. In this case, PulseAudio will be launched automatically regardless of the socket activation status.

For more information, see PulseAudio: Running.

Starting manually

PulseAudio can be manually started with:

$ pulseaudio --start

And stopped with:

$ pulseaudio --kill

Back-end configuration

ALSA

Install the pulseaudio-alsa package. It contains the necessary /etc/asound.conf for configuring ALSA to use PulseAudio. Also make sure that ~/.asoundrc does not exist, it would override the /etc/asound.conf file.

Also install lib32-libpulse and lib32-alsa-plugins if you run a x86_64 system and want to have sound for 32-bit multilib programs like Wine, Skype and Steam.

To prevent applications from using ALSA's OSS emulation and bypassing PulseAudio (thereby preventing other applications from playing sound), make sure the module snd_pcm_oss is not being loaded at boot. If it is currently loaded (lsmod | grep oss), disable it by executing:

# rmmod snd_pcm_oss

ALSA/dmix without grabbing hardware device

Note: This section describes alternative configuration, which is generally not recommended.

You may want to use ALSA directly in most of your applications while still being able to use applications which require PulseAudio at the same time. The following steps allow you to make PulseAudio use dmix instead of grabbing ALSA hardware device.

  • Remove package pulseaudio-alsa, which provides compatibility layer between ALSA applications and PulseAudio. After this your ALSA apps will use ALSA directly without being hooked by Pulse.
  • Edit /etc/pulse/default.pa.
Find and uncomment lines which load back-end drivers. Add device parameters as follows. Then find and comment lines which load autodetect modules.
load-module module-alsa-sink device=dmix
load-module module-alsa-source device=dsnoop
# load-module module-udev-detect
# load-module module-detect
  • Optional: If you use kdemultimedia-kmix you may want to control ALSA volume instead of PulseAudio volume:
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.kde4/env/kmix_disable_pulse.sh
$ chmod +x ~/.kde4/env/kmix_disable_pulse.sh
  • Now, reboot your computer and try running ALSA and PulseAudio applications at the same time. They both should produce sound simultaneously.
Use pavucontrol to control PulseAudio volume if needed.

OSS

There are multiple ways of making OSS-only programs output to PulseAudio:

ossp

Install ossp package and start osspd.service.

padsp wrapper

Programs using OSS can work with PulseAudio by starting it with padsp (included with PulseAudio):

$ padsp OSSprogram

A few examples:

$ padsp aumix
$ padsp sox foo.wav -t ossdsp /dev/dsp

You can also add a custom wrapper script like this:

/usr/local/bin/OSSProgram
#!/bin/sh
exec padsp /usr/bin/OSSprogram "$@"

Make sure /usr/local/bin comes before /usr/bin in your PATH.

GStreamer

Install gst-plugins-good, or gstreamer0.10-good-plugins if your intended program has a legacy GStreamer implementation.

OpenAL

OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so:
/etc/openal/alsoft.conf
drivers=pulse,alsa

libao

Edit the libao configuration file:

/etc/libao.conf
default_driver=pulse

Be sure to remove the dev=default option of the alsa driver or adjust it to specify a specific Pulse sink name or number.

Note: You could possibly also keep the libao standard of outputting to the alsa driver and its default device if you install pulseaudio-alsa since the ALSA default device then is PulseAudio.

Equalizer

Warning: The equalizer module is considered unstable and might be removed from PulseAudio. For more, see the mailing list.

PulseAudio has an integrated 10-band equalizer system. In order to use the equalizer do the following:

Install pulseaudio-equalizer:

Load equalizer sink and dbus-protocol module

$ pactl load-module module-equalizer-sink
$ pactl load-module module-dbus-protocol

GUI front-end

run:

$ qpaeq
Note: If qpaeq has no effect, install pavucontrol and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.

Load equalizer and dbus module on every boot

Edit the /etc/pulse/default.pa or ~/.config/pulse/default.pa file with your favorite editor and append the following lines:

### Load the integrated PulseAudio equalizer and D-Bus module
load-module module-equalizer-sink
load-module module-dbus-protocol
Note: The equalizer sink needs to be loaded after the master sink is already available.

Applications

QEMU

Merge-arrows-2.pngThis article or section is a candidate for merging with QEMU.Merge-arrows-2.png

Notes: QEMU is the most complex of the "applications" described in this section, merging to the main article would provide better context. (Discuss in Talk:PulseAudio#)

The audio driver used by QEMU is set with the QEMU_AUDIO_DRV environment variable:

$ export QEMU_AUDIO_DRV=pa

Run the following command to get QEMU's configuration options related to PulseAudio:

$ qemu-system-x86_64 -audio-help | awk '/Name: pa/' RS=

The listed options can be exported as environment variables, for example:

$ export QEMU_PA_SINK=alsa_output.pci-0000_04_01.0.analog-stereo.monitor
$ export QEMU_PA_SOURCE=input

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: The following is not specific to PulseAudio. (Discuss in Talk:PulseAudio#)

To get list of the supported emulation audio drivers

$ qemu-system-x86_64 -soundhw help

To use e.g. ac97 driver for the guest use the -soundhw ac97 commnad with QEMU.

Note: Video graphic card emulated drivers for the guest machine may also cause a problem with the sound quality. Test one by one to make it work. You can list possible options with qemu-system-x86_64 -h | grep vga.

AlsaMixer.app

Make alsamixer.appAUR dockapp for the windowmaker use pulseaudio, e.g.

$ AlsaMixer.app --device pulse

Here is a two examples where the first one is for ALSA and the other one is for pulseaudio. You can run multiple instances of it. Use the -w option to choose which of the control buttons to bind to the mouse wheel.

# AlsaMixer.app -3 Mic -1 Master -2 PCM --card 0 -w 1
# AlsaMixer.app --device pulse -1 Capture -2 Master -w 2
Note: It can use only those output sinks that set as default.

XMMS2

Make it switch to pulseaudio output

$ nyxmms2 server config output.plugin pulse

and to alsa

$ nyxmms2 server config output.plugin alsa

To make xmms2 use a different output sink, e.g.

 $ nyxmms2 server config pulse.sink alsa_output.pci-0000_04_01.0.analog-stereo.monitor

See also the official guide [3].

KDE Plasma Workspaces and Qt4

PulseAudio will automatically be used by KDE/Qt4 applications. It is supported by default in the KDE sound mixer. For more information see the KDE page in the PulseAudio wiki. One useful tidbit from that page is to add load-module module-device-manager to /etc/pulse/default.pa.

If the phonon-gstreamer backend is used for Phonon, GStreamer should also be configured as described in #GStreamer.

Audacious

Audacious natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.

Java/OpenJDK 6

Create a wrapper for the Java executable using padsp as seen on the Java sound with PulseAudio page.

Music Player Daemon (MPD)

configure MPD to use PulseAudio. See also MPD/Tips and Tricks#MPD and PulseAudio.

MPlayer

MPlayer natively supports PulseAudio output with the -ao pulse option. It can also be configured to default to PulseAudio output, in ~/.mplayer/config for per-user, or /etc/mplayer/mplayer.conf for system-wide:

/etc/mplayer/mplayer.conf
ao=pulse

guvcview

guvcview when using the PulseAudio input from a Webcam may have the audio input suspended resulting in no audio being recorded. You can check this by executing:

$ pactl list sources

If the audio source is "suspended" then modifying the following line in /etc/pulse/default.pa and changing:

load-module module-suspend-on-idle

to

#load-module module-suspend-on-idle

And then either restarting PulseAudio or your computer will only idle the input source instead of suspending it. guvcview will then correctly record audio from the device.

Tips and tricks

Keyboard volume control

Map the following commands to your volume keys: XF86AudioRaiseVolume, XF86AudioLowerVolume, XF86AudioMute

First find out which sink corresponds to the audio output you'd like to control. To list available sinks:

pactl list sinks short

Suppose sink 0 is to be used, to raise the volume:

sh -c "pactl set-sink-mute 0 false ; pactl set-sink-volume 0 +5%"

To lower the volume:

sh -c "pactl set-sink-mute 0 false ; pactl -- set-sink-volume 0 -5%"

To mute/unmute the volume:

pactl set-sink-mute 0 toggle

To mute/unmute the microphone:

pactl set-source-mute 1 toggle

Play sound from a non-interactive shell (systemd service, cron)

Set XDG_RUNTIME_DIR before the command (replace user_id with the ID of the user running PulseAudio):

XDG_RUNTIME_DIR=/run/user/user_id paplay /usr/share/sounds/freedesktop/stereo/complete.oga

Or use machinectl:

# machinectl shell .host --uid=user_id /usr/bin/paplay /usr/share/sounds/freedesktop/stereo/complete.oga

X11 Bell Events

To get pulseaudio to handle X11 bell events, run the following commands after the X11 session has been started:

pactl upload-sample /usr/share/sounds/freedesktop/stereo/bell.oga x11-bell
pactl load-module module-x11-bell sample=x11-bell display=$DISPLAY

To adjust the volume of the X11 bell, run the following command:

xset b 100

100 is a percentage. This requires the xorg-xset package. See Autostarting for a way to run these commands automatically when the X11 session is started.

Switch on connect

This is a module used to switch the output sound to the newly connected device. For example, if you plug in a USB headset, the output will be switched to that. If you unplug it, the output will be set back to the last device. This used to be quite buggy but got a lot of attention in PulseAudio 8.0 and should work quite well now.

If you just want to test the module then you can load it at runtime by calling:

# pactl load-module module-switch-on-connect

If you want to make the change persistent you will have to add it to your local pulseaudio settings or to /etc/pulse/default.pa (system wide effect). In either case, add this line:

load-module module-switch-on-connect

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Editing /usr/bin/start-pulseaudio-x11 will not survive package upgrade. The offending module can be unloaded in the config before loading module-switch-on-connect, see Talk:Bluetooth_headset#GDMs_pulseaudio_instance_captures_bluetooth_headset. (Discuss in Talk:PulseAudio#)

On KDE/Plasma5 you should furthermore disable module-device-manager. As soon as Plasma5 is started it loads (via start-pulseaudio-x11) the module module-device-manager for pulseaudio to manage the devices. But that module apparently conflicts with module-switch-on-connect. Therefore you should disable that module by editing /bin/start-pulseaudio-x11 and commenting the lines for KDE. Simply logout and login again and in order to renew your pulseaudio session. On connect switching should now work properly.

Troubleshooting

See PulseAudio/Troubleshooting.

See also