HDMI audio
After faffing with headphones and Bluetooth for literally 18 months I realised I could pipe my PC’s audio into the monitor.
Here’s what I ended up doing.
pactl list short sinks
The pactl
(which I have been thinking of as ‘pact-al’ when of course it’s ‘p(ulse) a(udio) control’) program lets me talk to a running PulseAudio server. This command lists all the available ‘sinks’ (output devices) in a short format.
so now I can do this:
```bash
pactl set-card-profile alsa_card.pci-0000_01_00.1 output:hdmi-stereo-extra1
…to switch from whatever was controlling the headphone jack to the HDMI output. See:
joe@joe-main:~$ pactl list short sinks
1 alsa_output.pci-0000_0c_00.6.iec958-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
253 alsa_output.pci-0000_01_00.1.hdmi-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
joe@joe-main:~$
But not so fast - because now the audio is coming out of the wrong monitor - I have a nice big TV monitor and an old second monitor and the sound is coming out of the wrong one!
So now I have to go into more detail. This command lists all audio cards with detailed information:
pactl list cards
The output is very long but it tells me I have three cards.
- AMD HD Audio Controller: this is the onboard audio controller integrated with my AMD Ryzen 3 CPU and ASUS motherboard and is presumably what I plug my headphones into on my tower.
- NVIDIA HDA (High-Definition Audio): This is the audio output provided by my NVIDIA GeForce RTX 3050 GPU. It handles audio output over HDMI connections. It also tells me which HDMI ports are connected.
- A third card (AMD Radeon HD Audio Controller): its use is unclear.
Now I can use this command:
pactl set-card-profile alsa_card.pci-0000_01_00.1 output:hdmi-stereo-extra1
To set the correct HDMI output (I got the stereo-extra1 part from listing the cards). I also set the default:
pactl set-default-sink alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1
But that doesn’t appear to survive a reboot. More to do here…