Use PulseAudio to handle the sound system

Use PulseAudio to handle the sound system

Dec 14, 2022 09:37 PM
Last edited time
May 22, 2023 09:24 PM
PulseAudio is a powerful sound system that manages all the sound devices in your system.

Audio Layout

I have three speakers. Speaker A is directly connected to the motherboard audio card. Speaker B is connected to a monitor and then to the GPU through DisplayPort. In addition, I have a monitor that has an embedded speaker.
I want to use Speaker B as my default speaker to play music.

PulseAudio configuration

Normally, you can use a graphic interface of PulseAudio. There’re many of them in AUR. But today, I only want to solve the problem with its command line interface.
First, check all the interfaces you have in your system discovered by PulseAudio.
❯ pacmd list-cards 3 card(s) available. index: 0 name: <alsa_card.usb-MACROSILICON_2109-02> .... index: 1 name: <alsa_card.pci-0000_07_00.1> driver: <module-alsa-card.c> owner module: 7 properties: .... device.product.name = "GA102 High Definition Audio Controller" profiles: output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 38668, available: unknown) output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 38468, available: unknown) ....
So I got my card name <alsa_card.pci-0000_07_00.1>. I also got the profile using Speaker B (connected to the HDMI 2 interface) named output:hdmi-stereo-extra1.
Now, if I want to switch to Speaker B, I can use the following command:
pactl set-card-profile alsa_card.pci-0000_07_00.1 output:hdmi-stereo-extra1
If I want to make the config permanent, I can edit the file /etc/pulse/default.pa, and add to the bottom.
set-card-profile alsa_card.pci-0000_07_00.1 output:hdmi-stereo-extra1