If I can send audio to the output devices, then I can record the same audio as a wave. With filesystems, you can just setup a loopback filesystem and write binary data on a file instead of a device.
My question is: Can I send the audio signal to a (for instance) WAV file instead of my audio devices? How?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Yes.
Actually there are lots of ways. You can set up a sound dummy sound card device that you can just rip the data out of the device … however this isn’t a very useful format.
More useful to you is something like the arecord utility that allows you to eavesdrop on the alsa output stream and save it to several known formats. Basically anything that you can get to play over the alsa sound system can be copied to a standard format sound file.
Similar tools exist for pulse audio.
Method 2
If your system, or just the application you want to record, is directing its output to a sound server, look into recording possibilities for that sound server. For example, on Ubuntu, the official sound server is PulseAudio, which comes with the parec command (from the pulseaudio-utils package Install pulseaudio-utils http://bit.ly/software-small). You may need to convert the output from parec into something usable with SoX (Ubuntu: sox Install sox http://bit.ly/software-small).
parec -r --rate=44100 | sox --type raw --rate 44100 - --type ogg recording.ogg
Method 3
It is supposed to be possible to record directly in to Audacity, but I couldn’t get that to work on my system (Ubuntu 10.10).
So following the instructions here from the Audacity wiki, I use the ALSA playback device to divert the audio to a file.
This uses an .asoundrc file (in your home directory):
pcm.teeraw {
type empty
slave.pcm "tee:default,'/tmp/out.raw',raw"
# 48000 S16_LE 2ch (aplay -t raw -f dat)
}
For recording from flash (on firefox), I use
FLASH_ALSA_DEVICE=teeraw firefox
The resulting file, /tmp/out.raw is in raw format so converting it needs knowing what the right parameters are.
Bizarrely, lame seems able to work this out for itself but sox needs to know it explicitly.
So the following all seem to work:
aplay -t raw -f dat -r 44100 /tmp/out.raw # to play sox -r 44100 -b 16 -e signed -c 2 /tmp/out.raw /tmp/out.wav # to convert to wav lame /tmp/out.raw # to convert to mp3
Method 4
There is a loopback driver in the ALSA tree, aloop-kernel.c (via here); which you’d have to build yourself (and figure out its utilization as a a device through audio applications like aplay/arecord) …
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0