[pulseaudio-discuss] recording from speakers

Tanu Kaskinen tanuk at iki.fi
Wed Mar 7 23:53:16 PST 2012

On Wed, 2012-03-07 at 21:39 -0800, Laxmikant Rashinkar wrote:
> Hi,
> I'm brand new to pulseaudio. I want to dive right in and write a cmd 
> line application that records whatever is being played on the speaker to 
> a disk file (aka stereo mix).
> Can someone give me a general idea of how to go about doing this?

Output devices are represented by "sinks" and input devices are
represented by "sources" in Pulseaudio. Assuming that a sound card
supports both output and input, it usually shows up as one sink and one
source. In addition to that, every sink has an automatically generated
"monitor source" that can be used just like any other source. So,
whatever you play to a sink, you can record it from its monitor source.

Sinks and sources have names. The easiest way to recognize a monitor
source is looking at its name: the monitor source names always end with
".monitor". For example, "pactl list sinks | grep Name: ; pa list
sources | grep Name:" prints this on my system:

	Name: alsa_output.pci-0000_00_1b.0.analog-stereo
	Name: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
	Name: alsa_input.pci-0000_00_1b.0.analog-stereo

The first one is the sink name for my laptop's internal sound card's
output, the second one is the monitor source for that sink, and the
third one is the source name for the internal sound card's input.

I hope the concept of monitor sources is now clear. You'll just have to
make an application that records from the monitor sources. I don't know
how you'll want to handle the case where the system has multiple sound


More information about the pulseaudio-discuss mailing list