Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers

up vote 8 down vote accepted

Yes.

Actually there are lots of ways. You can setup 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 evesdrop 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.

share|improve this answer
add comment

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). You may need to convert the output from parec into something usable with SoX (Ubuntu: sox Install sox).

parec -r --rate=44100 | sox --type raw --rate 44100 - --type ogg recording.ogg
share|improve this answer
    
that didn't work for me, but this variation-on-the-theme did: askubuntu.com/questions/60837/… –  ixtmixilix Aug 19 '12 at 12:52
add comment

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
share|improve this answer
add comment

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) ...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.