PulseAudio allows for simultaneous output to multiple sources. In this example, some applications are configured to use HDMI while others are configured to use analog. Multiple applications are able to receive audio at the same time.

+

=== Defaulting an Analog Output Source ===

{{Note| To list devices aplay is used. This program is part of the alsa-utils package and is NOT required to output to multiple sources. It is required to list playback devices therefore users can remove this package when finished with it.}}

{{Note| To list devices aplay is used. This program is part of the alsa-utils package and is NOT required to output to multiple sources. It is required to list playback devices therefore users can remove this package when finished with it.}}

−

First, users need to understand the system's audio layout. This is accomplished using ''aplay'' which is part of the {{pkg|alsa-utils}} package.

+

To select an alternative source as the default output (for example analog), first list all sources:

On this machine, the analog source is card 0, device 0. Edit {{ic|/etc/pulse/default.pa}} and append the following to add the analog source:

+

load-module module-alsa-sink device=hw:0,0

+

+

Determine the correct index of the new source:

+

$ pacmd list-sinks | less

+

+

Note the index number that corresponds to the 'alsa_output.hw_0_0' sink.

+

+

Finally, add a 2nd line to {{ic|/etc/pulse/default.pa}} defining the analog output to be used by default:

+

set-default-sink 2

+

+

Either logout/login or restart pulseaudio manually for these changes to take effect.

+

+

=== Simultaneous HDMI and Analog Output ===

+

PulseAudio allows for simultaneous output to multiple sources. In this example, some applications are configured to use HDMI while others are configured to use analog. Multiple applications are able to receive audio at the same time.

{{bc|$ aplay -l

{{bc|$ aplay -l

**** List of PLAYBACK Hardware Devices ****

**** List of PLAYBACK Hardware Devices ****

Line 36:

Line 61:

Also see [https://bbs.archlinux.org/viewtopic.php?id=118026 this thread] for a variation on this theme and [http://www.freedesktop.org/wiki/Software/PulseAudio/FAQ#Can_I_use_PulseAudio_to_playback_music_on_two_sound_cards_simultaneously.3F PulseAudio FAQ].

Also see [https://bbs.archlinux.org/viewtopic.php?id=118026 this thread] for a variation on this theme and [http://www.freedesktop.org/wiki/Software/PulseAudio/FAQ#Can_I_use_PulseAudio_to_playback_music_on_two_sound_cards_simultaneously.3F PulseAudio FAQ].

+

+

=== Using MPD with PulseAudio running as the mpd user ===

+

This scenario is described in the [[https://wiki.archlinux.org/index.php/Music_Player_Daemon/Tips_and_Tricks#Local_.28with_separate_mpd_user.29 MPD Tips and Tricks]] article.

===Surround sound systems===

===Surround sound systems===

Line 157:

Line 185:

===PulseAudio over network===

===PulseAudio over network===

−

One of PulseAudio's magnificent features is the possibility to stream audio from clients over TCP to the server running the PulseAudio daemon, allowing sound to be streamed through the LAN.

+

One of PulseAudio's unique features is its ability to stream audio from clients over TCP to a server running the PulseAudio daemon reliably within a LAN.

−

To accomplish this, one needs to enable module-native-protocol-tcp, and copy the pulse-cookie to the clients.

+

To accomplish this, one needs to enable module-native-protocol-tcp.

====TCP support (networked sound)====

====TCP support (networked sound)====

−

To enable the TCP module, add this to (or uncomment, if already there) {{ic|/etc/pulse/default.pa}}:

+

To enable the TCP module, add this to (or uncomment, if already there) {{ic|/etc/pulse/default.pa}} on both the client and server:

load-module module-native-protocol-tcp

load-module module-native-protocol-tcp

+

+

For this to work, it is a requirement that both the client and server share the same cookie. Ensure that the clients and server share the same cookie file found under {{ic|~/.config/pulse/cookie}}. It does not matter whose cookie file you use (the server or a client's), just that the server and client(s) share the same one.

Note: If experiencing trouble connecting, use (on server)

Note: If experiencing trouble connecting, use (on server)

−

pacmd>> list-modules

+

pacmd list-modules

====TCP support with anonymous clients====

====TCP support with anonymous clients====

−

If it is undesirable to copy the pulse-cookies from clients, allow anonymous clients, by giving these parameters to module-native-protocol-tcp (again in {{ic|/etc/pulse/default.pa}}):

+

If it is undesirable to copy the cookie file from clients, anonymous clients can access the server by giving these parameters to module-native-protocol-tcp on the server (again in {{ic|/etc/pulse/default.pa}}):

Remember to change the LAN ip prefix should it be different from 192.168.0.0.

+

Change the LAN IP subnet to match that of the those clients you wish to have access to the server.

====Zeroconf (Avahi) publishing====

====Zeroconf (Avahi) publishing====

−

For the remote Pulseaudio server to appear in the PulseAudio Device Chooser ({{ic|padevchooser}}), load the appropriate zeroconf modules as well as to enable Avahi. On both machines add {{ic|avahi-daemon}} to the DAEMONS in rc.conf.

+

For the remote Pulseaudio server to appear in the PulseAudio Device Chooser ({{ic|pasystray}}), load the appropriate zeroconf modules, and enable the [[Avahi]] [[daemon]].

+

+

On both machines run:

+

$ systemctl start avahi-daemon.service

+

$ systemctl enable avahi-daemon.service

On the server, add {{ic|load-module module-zeroconf-publish}} to /etc/pulse/default.pa, on the client, add {{ic|load-module module-zeroconf-discover}} to {{ic|/etc/pulse/default.pa}}. Now redirect any stream or complete audio output to the remote pulseaudio server by selecting the appropriate sink.

On the server, add {{ic|load-module module-zeroconf-publish}} to /etc/pulse/default.pa, on the client, add {{ic|load-module module-zeroconf-discover}} to {{ic|/etc/pulse/default.pa}}. Now redirect any stream or complete audio output to the remote pulseaudio server by selecting the appropriate sink.

+

+

If you have issues with the remote syncs appearing on the client, try restarting the avahi daemon on the server to rebroadcast the available interfaces.

Defaulting an Analog Output Source

Note: To list devices aplay is used. This program is part of the alsa-utils package and is NOT required to output to multiple sources. It is required to list playback devices therefore users can remove this package when finished with it.

To select an alternative source as the default output (for example analog), first list all sources:

On this machine, the analog source is card 0, device 0. Edit /etc/pulse/default.pa and append the following to add the analog source:

load-module module-alsa-sink device=hw:0,0

Determine the correct index of the new source:

$ pacmd list-sinks | less

Note the index number that corresponds to the 'alsa_output.hw_0_0' sink.

Finally, add a 2nd line to /etc/pulse/default.pa defining the analog output to be used by default:

set-default-sink 2

Either logout/login or restart pulseaudio manually for these changes to take effect.

Simultaneous HDMI and Analog Output

PulseAudio allows for simultaneous output to multiple sources. In this example, some applications are configured to use HDMI while others are configured to use analog. Multiple applications are able to receive audio at the same time.

The key to a configuration like this is to understand that whatever is selected in pavucontrol under Configuration>Internal AUdio is the default device. Load pavucontrol>Configuration and select HDMI as the profile.

Add the following to /etc/pulse/default.pa to setup the analog as a secondary source:

Now start a program that will use pulseaudio such as mplayer, vlc, mpd, etc. and switch to the "Playback" tab. A pulldown should be available for the running program to select one of the three sources.

Using MPD with PulseAudio running as the mpd user

Surround sound systems

Many people have a surround card, but have speakers for just two channels, so PulseAudio cannot really default to a surround setup. To enable all the channels, edit /etc/pulse/daemon.conf: uncomment the default-sample-channels line (i.e. remove the semicolon from the beginning of the line) and set the value to 6 For a 5.1 setup, or 8 for a 7.1 setup etc.

ALSA Monitor source

To be able to record from a monitor source (a.k.a. "What-U-Hear", "Stereo Mix"), use pactl list to find out the name of the source in Pulseaudio (e.g. alsa_output.pci-0000_00_1b.0.analog-stereo.monitor). Then add lines like the following to /etc/asound.conf or ~/.asoundrc:

The original title for this section indicated the problem is specific to nVidia cards. As seen in this forum thread other cards are affected as well. The rest of the section will use an nVidia card as a case-study but the solution should carry over for people using other affected cards.

Testing for the correct card

Now a list of the detected cards is known, users will need to test for which one is outputing to the tv/monitor

# aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Right.wav

where 1 is the card and 3 is the device substitute in the values listed from the previous section. If there is no audio then try substituting a different device (on my card I had to use card 1 device 7)

Manually configuring pulseaudio to detect the Nvidia HDMI

Having identified which HDMI device is working, PulseAudio can be fored to use it via an edit to

/etc/pulse/default.pa

:

# load-module module-alsa-sink device=hw:1,7

where the 1 is the card and the 7 is the deivce found to work in the previous section

restart pulse audio

# killall pulseaudio

open the sound settings manager, make sure that under the hardware tab the graphics cards HDMI audio is set to "Digital Stereo (HDMI) Output" ( My graphics card audio is called "GF100 High Definition Audio Controller"

Then open the output tab there should now be two HDMI outputs for the graphics card test which one works by selecting one of them and then using a program to play audio i.e use vlc to play a movie if it doesn't work the select the other.

PulseAudio over network

One of PulseAudio's unique features is its ability to stream audio from clients over TCP to a server running the PulseAudio daemon reliably within a LAN.

To accomplish this, one needs to enable module-native-protocol-tcp.

TCP support (networked sound)

To enable the TCP module, add this to (or uncomment, if already there) /etc/pulse/default.pa on both the client and server:

load-module module-native-protocol-tcp

For this to work, it is a requirement that both the client and server share the same cookie. Ensure that the clients and server share the same cookie file found under ~/.config/pulse/cookie. It does not matter whose cookie file you use (the server or a client's), just that the server and client(s) share the same one.

Note: If experiencing trouble connecting, use (on server)

pacmd list-modules

TCP support with anonymous clients

If it is undesirable to copy the cookie file from clients, anonymous clients can access the server by giving these parameters to module-native-protocol-tcp on the server (again in /etc/pulse/default.pa):

On the server, add load-module module-zeroconf-publish to /etc/pulse/default.pa, on the client, add load-module module-zeroconf-discover to /etc/pulse/default.pa. Now redirect any stream or complete audio output to the remote pulseaudio server by selecting the appropriate sink.

If you have issues with the remote syncs appearing on the client, try restarting the avahi daemon on the server to rebroadcast the available interfaces.

Switching the PulseAudio server used by local X clients

To switch between servers on the client from within X, the pax11publish command can be used. For example, to switch from the default server to the server at hostname foo:

$ pax11publish -e -S foo

Or to switch back to the default:

$ pax11publish -e -r

Note that for the switch to become apparent, the programs using Pulse must be restarted.

PulseAudio through JACK the new new way

Server auto-launching is implemented as D-Bus call that auto-activates JACK D-Bus service, in case it is not already started, and starts the JACK server. Correct interaction with PulseAudio is done using a D-Bus based audio card "acquire/release" mechanism. When JACK server starts, it asks this D-Bus service to acquire the audio card and PulseAudio will unconditionally release it. When JACK server stops, it releases the audio card that can be grabbed again by PulseAudio.

module-jackdbus-detect.so dynamically loads and unloads module-jack-sink and module-jack-source when jackdbus is started and stopped.

If PulseAudio sound does not work, check with pavucontrol to see if the relevant programs appear in the playback tab. If not, add the following to ~/.asound.conf or /etc/asound.conf to redirect ALSA to PulseAudio:

If it still doesn't work, check with pavucontrol in the playback tab and make sure the relevant programs are outputting to PulseAudio JACK Sink instead of your audio card (which JACK has control of, so it won't work).

PulseAudio through JACK the new way

The basic idea is that killing PulseAudio is bad idea, it may crash any apps using PulseAudio, and disrupt any audio playing

Pulseaudio through JACK the old way

The JACK-Audio-Connection-Kit is popular for audio work, and is widely supported by Linux audio applications. It fills a similar niche as Pulseaudio, but with more of an emphasis on professional audio work. In particular, audio applications such as Ardour and Audacity (recently) work well with Jack.

Pulseaudio provides module-jack-source and module-jack-sink which allow Pulseaudio to be run as a sound server above the JACK daemon. This allows the usage of per-volume adjustments and the like for the apps which need it, play-back apps for movies and audio, while allowing low-latency and inter-app connectivity for sound-processing apps which connect to JACK. However, this will prevent Pulseaudio from directly writing to the sound card buffers, which will increase overall CPU usage.

To just try PA on top of jack, have PA load the necessary modules on start:

pulseaudio -L module-jack-sink -L module-jack-source

To use pulseaudio with JACK, JACK must be started up before Pulseaudio, using whichever method one prefers. sPulseaudio then needs to be started loading the 2 relevant modules. Edit /etc/pulse/default.pa, and change the following region:

Basically, this prevents module-udev-detect from loading. module-udev-detect will always try to grab the sound-card (JACK has already done that, so this will cause an error). Also, the jack source and sink must be explicitly loaded.

QjackCtl with Startup/Shutdown Scripts

Using the settings listed above, use QjackCtl to execute a script upon startup and shutdown to load/unload PulseAudio. Part of the reason users may wish to do this is that the above changes disable PulseAudio's automatic hardware detection modules. This particular setup is for using PulseAudio in an exclusive fashion with JACK, though the scripts could be modified to unload and load an alternate non-JACK setup, but killing and starting PulseAudio while programs might be using it would become problematic.

The following example could be used and modified as necessary as a startup script that daemonizes PulseAudio and loads the padevchooser program (optional, needs to be built from AUR) called jack_startup:

then with QjackCtl loaded, click on the Setup button and then the Options tab and tick both "Execute Script after Startup:" And "Execute Script on Shutdown:" and put either use the ... button or type the path to the scripts (assuming the scripts are in the home directory) ~/jack_startup and ~/jack_shutdown making sure to save the changes.

Pulseaudio through OSS

Add the following to /etc/pulse/default.pa:

load-module module-oss

Then start Pulseaudio as usual making sure that sinks and sources are defined forOSS devices.

Pulseaudio from within a chroot (ex. 32-bit chroot in 64-bit install)

Since a chroot sets up an alternative root for the running/jailing of applications, pulseaudio must be installed within the chroot itself (pacman -S pulseaudio within the chroot environment).

Pulseaudio, if not set up to connect to any specific server (this can be done in /etc/pulse/client.conf, through the PULSE_SERVER environment variable, or through publishing to the local X11 properties using module-x11-publish), will attempt to connect to the local pulse server, failing which it will spawn a new pulse server. Each pulse server has a unique ID based on the machine-id value in /var/lib/dbus. To allow for chrooted apps to access the pulse server, the following directories must be mounted within the chroot:-

/var/run
/var/lib/dbus
/tmp
~/.pulse

/dev/shm should also be mounted for efficiency and good performance. Note that mounting /home would normally also allow sharing of the ~/.pulse folder.

For specific direction on accomplishing the appropriate mounts, please refer to the wiki on installing a bundled 32-bit system, especially the additional section specific to Pulseaudio.

System-wide Equalizer

Pulseaudio can be configured to sound much better through the use of a system-wide equalizer. There are a few tools to do this. Extra information on the cons of each here . Individual apps can be excluded via pavucontrol .

pulseaudio-equalizer

Note: If users remove pulseaudio-equalizer, be sure should comment out the respective generated section in $HOME/.pulse/default.pa or risk strange issues.

Note: If users have trouble with the volume resetting to the maximum level or making harsh noise upon switching sound sources, do this and then find the "Equalized audio configuration" section in $HOME/.pulse/default.pa and comment out only the "set-sink-volume" line there.

qpaeq

A simple qt tool that comes with pulseaudio and includes support for more bands than pulseaudio-equalizer (just resize the window horizontally), but presently lacks easily accessible presets and may need to be set as the default manually. Located at /usr/bin/qpaeq and requires python2-pyqt to run.

Note: If qpaeq crashes at startup, be sure that load-module module-equalizer-sink is in /etc/pulse/default.pa or $HOME/.pulse/default.pa

Note: If the equalizer has no effect (e.g., setting the qpaeq preamp bar to zero doesn't mute all sound), check that a link to applications' audio sinks to the equalizer. Do this by adding the line set-default-sink equalized to /etc/pulse/default.pa or $HOME/.pulse/default.pa.

Disabling Auto Spawning of PulseAudio Server

Some users may prefer to manually start the pulseaudio server before running certain programs and then stop the pulseaudio server when they are finished. A simple way to accomplish this is to edit /etc/pulse/client.conf and change autospawn = yes to autospawn = no, and set daemon-binary to /bin/true. Make sure the two lines are uncommented as well.

/etc/pulse/client.conf

autospawn = no
daemon-binary = /bin/true

Now you can manually start the pulseaudio server with

$ pulseaudio --start

and stop it with

$ pulseaudio --kill

You may also have to move or delete a .desktop file in /etc/xdg/autostart if it exists.