Via ALSA emulation
I don't have a Debian 6.0.x box to test on, but I think this way will probably work. Courtesy an example on the Arch wiki.
pacmd list-sources to find the name of your sound card's monitor stream. Grep for
.monitor works pretty well:
$ pacmd list-sources | grep '\.monitor'
I have two cards, hence two monitors. Then edit your
~/.asoundrc to set up an ALSA device for it, by adding lines like (but of course use your monitor device name, not mine):
arecord -f s16_le -t wav -r 44100 -D pulse_monitor /tmp/outfile.wav to record.
Older PulseAudio Utilities
Instead of using ALSA emulation, you can use
parecord on the monitor you found above. Do so like this:
parecord -d alsa_output.usb-stereo-link_stereo-link_1200_USB_DAC-00-DAC.analog-stereo.monitor outfile.wav. That should work with
parec as well (in the LAME example below)
Newer PulseAudio Utilities
PulseAudio ships with a
parecord command-line utility that can record sound going through it.
To use it, first find the index of the stream you want to capture. Easy way from the command line is
pacmd list-sink-inputs, which should give something like this:
1 sink input(s) available.
client: 87 <Chromium>
I've omitted a bunch of lines; but you can see that's Chromium (where I have a music player running). The
index: 10720 bit is important.
To record it, it's as simple as
parecord --monitor-stream 10720 outfile.wav. You can also write the output to stdout and use it as part of a pipe with
parec; for example if you're short on disk space you could directly encode to MP3:
parec --monitor-stream 10720 --format s16le --channels 2 --rate 44100 \
| lame -r -s 44.1 -b 16 --signed --little-endian --preset medium /dev/stdin outfile.mp3