Recording Live Playback using ALSA
June 1, 2006
Have you ever felt the urge to record some “live” music while you are listening to
it? The following procedure might do what you want.
Prerequisites: The sound on your computer should use a 1.x release of the ALSA
drivers (say Linux version 2.6.x) and you have alsa-lib (Debian’s libasound2)
Assumptions: You don’t already have a $HOME/.asoundrc file. If you do then you
need to edit it suitably. You also should not have a script/program called recording
Result: You run recording -on to start recording. You then start your
live playback. After you have had enough you stop the live playback. You
then run recording -off and are left with a (large) file containing the
- First create a file called $HOME/.asoundrc like the enclosed asoundrc.txt.
- Create the links.
ln -s /dev/null /var/tmp/null.raw
ln -s /var/tmp/null.raw /var/tmp/record.raw
- Next install a script recording somewhere in the search path for executables
for your shell. This script should look like the enclosed recording.txt.
- That’s it!
- This only works for digital live playback through the PCM device of your
soundcard. You can use arecord for the other devices since these can
usually be “captured”.
- Don’t forget to copy/convert your recording /var/tmp/sound.raw to a
- This only works with audio players that support ALSA plugins. To get
it to work with other players like realplay, install alsa-oss and use
aoss realplay instead of realplay.
- You usually cannot run recording -on/-off while the player has the
audio device open. For many players (in particular those like (3) above),
you must quit the player before and after recording.
- The supplied asoundrc converts the incoming audio to CD format. This
may lead to a loss in quality but I prefer it to guessing the real format of
the raw data in each case.