$HOME/.asoundrc file:
pcm.save {
type file
format wav
slave.pcm front
# my main PCM is called front
file output.wav
}
Afterwards, you can use this save PCM with the tools that understand it, such as aplay or mplayer:
~ aplay -Dsave stuff.wav ~ mplayer -ao alsa:device=save stuff.wav
(for xine users, you may want to have a look at the audio.device.alsa_front_device configuration element).
Funnier, though, is the possibility to use it with programs that don't provide such an easy way to change that, (say, the flash player in a browser ?) via the use of the default PCM specification in $HOME/.asoundrc:
pcm.!default save
After that, all programs using the default PCM will save the sound they play as a save.wav file in their current directory - but nothing stops you from specifiying an absolute directory. Better yet, you may apparently use pipes in stead of the file name, à la popen.