PulseAudio via GUI: Pavucontrol (Shallow Thoughts)

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Mon, 04 May 2020

PulseAudio via GUI: Pavucontrol

(Note: this is not an alphabet post. You may have noticed I'm a little stuck on I. I hope to get un-stuck soon; but first, here are a pair of articles on configuring audio on Linux.)

I'm a very late adopter for PulseAudio. In the past, on my minimal Debian machines, nearly any sound problem could be made better by apt-get remove pulseaudio. But pulse seems like it's working better since those days, and a lot of applications (like Firefox) require it, so it's time to learn how to use it. Especially in these days of COVID-19 and video conferencing, when I'll need to be using the microphone and speakers a lot more. (I'd never actually had a reason to use the microphone on my last laptop.)

Beginner tutorials always start with something like "Go into System Preferences and click on Audio", leaving out anyone who doesn't use the standard desktop. The standard GUI PulseAudio controller is pavucontrol. It has four tabs.

[Configuration tab in pavucontrol]

Start with the rightmost Configuration tab, which lists your sound cards. In my case, I have the sound card that's built in to my laptop (Cannon Point is one of Intel's place-name codes, after a nature preserve in Georgia). I also have "USB PnP Audio Device", because the USB-C hub I use as a docking station has a sound card built into it.

When I first booted Ubuntu, I had no sound. It turned out that PulseAudio saw that I had a USB sound card plugged in and assumed that I wanted to use it. That seems reasonable, but it's wrong; I didn't own any speakers that I could plug into that sound card, and the only reason it's plugged in is that it's part of the hub. So the trick was to set Profile for the USB card to Off so Pulse would use the built-in sound. (I also had to do some extra fiddling to get the volume up to audible levels; pavucontrol's volume control sliders weren't enough.)

But gradually my sound setup grew more complicated. My built-in mic wasn't supported by older kernels, so for a while I used the little earbud headset that came with my phone, which worked surprisingly well for video conferencing. Eventually I ordered a USB microphone. Meanwhile, I got jealous of the nice speakers Dave has attached to his computer, and decided to buy some powered desktop speakers and plug them into the USB-C hub. And now, with the release of Ubuntu 20.04, the built-in microphone finally works too, so I have three possible mics if you count the headset. And don't forget HDMI, in case I plug in to a TV or a conference-room sound system.

That gives me a lot of possible combinations:

Card Output Input
Internal built-in speakers
plug-in headphones
HDMI
built-in mic
plug-in headset mic
USB-C hub powered speakers
plug-in headphones
plug-in headset mic
USB mic monitor earphone port USB mic

Now the pavucontrol profiles in the Configuration tab are getting more complicated. Here are the profiles for the USB sound card:

[Configuration profiles in pavucontrol]

[Output Devices in pavucontrol] But that's just the beginning. When I first tried the external speakers on Ubuntu 20.04, I didn't hear anything. When I went to the Output Devices tab, now there were five options (image at right), because the new driver for the Cannon Point sound card can output sound over HDMI as well as using the internal speakers. And it seems to have three of those HDMI options, even though I only have one HDMI monitor connected. And if you have an HDMI monitor connected, it assumes that monitor must have sound (not a good assumption) and prefers HDMI to the internal speakers.

One thing that helps is fallbacks. Note the button at the lower right that's circled in red. I'll come back to that soon.

Anyway, You can try muting all the output devices except for the speakers you want. But that isn't always enough, because of the fourth tab, Playback.

[Playback tab pavucontrol]

Initially, Playback only shows one entry, System Sounds. But when you run a program that plays sound, another entry will appear. It may show the name of the program you're running, or it may be named for the library that's producing the sound (for instance, my pygame-based music player program shows up as python: Simple directMedia Layer on).

You can increase the chances that most programs will use a particular device by marking that device as a fallback. In the Output Devices tab (everything I'm saying about Output Devices goes for Input Devices too), the rightmost button next to each device, a green checkbox, says Set as fallback if you hover over it: see the button that's circled red in the earlier screenshot. Some programs will ignore the fallback, though, especially if you've run them before. PulseAudio keeps a record somewhere of what device each app used the last time it was run, and will use that if it can. I haven't found any way of getting Pulse to display this mapping of apps to devices.

There's no visual indication to which device, if any, is the current fallback. (The next article will give a command-line way to tell.)

Pavucontrol works okay once you figure out the tricks. But changing inputs and outputs can be fiddly and requires a fair amount of clicking around. I hate doing that for things I do often: for instance, to switch to the external speakers so I can play music; or send output to HDMI because I'm giving a public presentation (assuming we eventally get past social distancing and have public meetings again); or, most important, turn off my microphone when I'm not using it.

So I wanted a quick, deterministic way of switching from the command line. I'll cover that in the next article.

Update: I ended up making it a separate page on my website, because I suspect I'll be tweaking it for quite a while. Controlling PulseAudio from the Command Line.

Tags: , , ,
[ 18:04 May 04, 2020    More linux | permalink to this entry | comments ]