Saturday, September 10, 2011

Recording with PulseAudio

Sometimes I find that I want to record the sound coming out of Hal's speakers. Say that my automatic recording of Prairie Home Companion goes south because an earthquake/hurricane/remnants of a tropical storm knocked out my power. It would be nice to be able to go the Prairie Home web site, click on the archive for the show, play the streaming download and record it.

I've done this kind of thing for years, mostly without the earthquakes. Occasionally there have been problems, but it's always possible to find a solution. After which I write it down so that I'll remember how to fix things.

Except sometimes my notes aren't helpful, because somebody decided it was a good idea to change things. Take a look at the above link. To be able to record sound, I'm suppose to open Gnome's Sound preferences, click on Recording, and click on Capture. Let's look at gnome-volume-control as it's shipped with Ubuntu 11.04:

Gnome Sound Preferences

Looks nothing like what was described above, does it?

So what happened? Beats me. All I know is that someone changed things, and that the changes have something to do with PulseAudio, Ubuntu's choice for sound.

Fortunately, there is a Ubuntu Wiki article that solved things for me. Of course, the information you want is buried way down at the bottom of the article, so let me summarize it here, down at the bottom of this article. (Yes, I admit to being long-winded.)

First, you need to set up the PulseAudio volume control. For reasons known only to Mark Shuttleworth, this isn't installed by default in 11.04, and goes by the perfectly obvious name of pavucontrol. So install it first,

sudo apt-get install pavucontrol

and open it, either by typing pavucontrol from the command line or clicking "PulseAudio Volume Control" under Applications=>Sound & Video. You'll get something like this:

PulseAudio Volume Control (pavucontrol)

Not very helpful, is it? The problem is that there is no application open trying to record sound. So let's open up Gnome Sound Recorder:

Gnome Sound Recorder (with nothing recording)

Start something playing, and press Record. PulseAudio will now look something like this:

Pulse Audio Volume Control with Gnome Sound Recorder Operating

The key to making things work is the line that says:

Sound Recorder: Record Stream from: …

You may have several options, but what you want is Monitor of Internal Audio Analog Stereo. When this is selected Gnome Sound Recorder will record what's coming out of the speakers, and will look something like this:

Gnome Sound Recorder recording

You can see it is recording as the brown (surprise!) bar at the bottom moves in time with the music's volume.

We'll leave the rest of this, e.g., recording directly to .ogg or .mp3, converting from .flac to .ogg, using Audacity instead of Sound Recorder, etc., as an exercise for the reader. Just remember, to record sound with Ubuntu 11.04, you need to use Pulse Audio Volume Control to tell whichever application you are using to record to monitor the internal audio.

Until someone decides it's time for a change.

3 comments:

Anonymous said...

We are past the year 2010, and the state of most Linux audio tools are still quite poor. Thank you for this post. Hopefully I can find a way to automate this on the commandline.

mac01021 said...

You're the man.

Anonymous said...

@Anonymous: pacmd enables you to send pulseaudio commands on the command-line.