Pulseaudio configuration

From wikinotes

Documentation

man pulse-daemon.conf https://man.archlinux.org/man/extra/pulseaudio/pulse-daemon.conf.5.en
man default.pa https://man.archlinux.org/man/default.pa.5
man pulse-client.conf https://man.archlinux.org/man/extra/libpulse/pulse-client.conf.5.en
man pulse-cli-syntax https://man.archlinux.org/man/pulse-cli-syntax.5
default devices https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/DefaultDevice/

Tutorials

archwiki: pulseaudio examples https://wiki.archlinux.org/title/PulseAudio/Examples

Locations

~/.config/pulse/daemon.conf

/etc/pulse/daemon.conf

user/global config
~/.config/pulse/default.pa

/etc/pulse/default.pa

user/global startup-script
~/.config/pulse/client.conf

/etc/pulse/client.conf

/etc/asound.conf alsa config (used by pulseaudio-alsa)

Files

default.pa

Basics

default.pa is essentially pulseaudio's rcfile.
If a user config is present, it will be read instead of the system config.
It is written using the pulseaudio cli syntax.

A common workflow is to include the system-config in the user-config,
but override the settings you are interested in.

# ~/.config/pulse/default.pa

# load defaults
.include /etc/pulse/default.pa

# your instructions
# (ignore failures caused by unloading modules that are not already loaded)
.nofail
unload-module ${module_to_unset}
.fail

Setting Default Devices

Sinks/Sources

  • sinks are speakers
  • sources are mics
pactl list short sinks            # list audio output devices
pactl list short sources          # list audio input devices

Temporarily set default mic and speakers

pactl set-default-sink   ${DEVICE}  # set default
pactl set-default-source ${DEVICE}  # set default

Permanently set default mic and speakers

# /etc/pulse/default.pa

pactl set-default-sink   ${DEVICE}  # set default
pactl set-default-source ${DEVICE}  # set default

Cards/Profiles

  • cards are devices capable of playing/recording audio
  • profiles are configurations for cards (for example, mono, stereo, 5.1-surround, ...)
# list audio-card indexes, names, and their profiles
pactl list cards | less -Ri

You'll be interested in the following headers (note: compressed for readability)

Card #0                                  # <-- card index
    Name: alsa_card.pci-0000_01_00.1     # <-- card name
        Profiles:                         # <--- all profiles
            output:hdmi-stereo: Digital Stereo (HDMI) Output \
                (sinks: 1, sources: 0, priority: 5900, available: no)

            input:analog-stereo: Analog Stereo Input \
                (sinks: 0, sources: 1, priority: 65, available: no)

            off: Off \
                (sinks: 0, sources: 0, priority: 0, available: yes)

            # ...
# /etc/pulse/default.pa

set-card-profile \
    alsa_card.pci-0000_01_00.1  `# card` \
    output:analog-stereo        `# profile`

daemon.conf

WARNING:

Setting the default-sample-rate has caused some wine programs to crash to desktop when they would not otherwise.
I was able to resolve it by assigning it alongside alternate-sample-rate but if applications are crashing it may be worth temporarily disabling it.
Workaround is not assigning it, starting a youtube video in any browser, launching game, and finally closing browser with youtube.

Adjust default/alternate sample rates etc.
See available sample formats

default-sample-rate = 48000
default-sample-channels = 2
default-sample-format = s24le

alternate-sample-rate = 44100

Check current settings using one/both of:

pacmd list-sinks | grep -e 'index:' -e 'name:' -e 'sample spec:'
less /proc/asound/card0/pcm0p/sub0/hw_params

Tips/Tricks

Most of these came from arch wiki.

Pops when starting/stopping playback

# default.pa
unload-module module-suspend-on-idle

Disable Remember Audio for Item

By default, pulseaudio attempts to remember the last device used for audio.
You can disable this.

# default.pa
load-module module-stream-restore restore_device=false