How to record audio playing on your computer using Audacity
Recently I wrote an article about different multimedia applications available for Linux. In that article I was asked(in a comment by Hugues) for a tool for Linux that could record Live audio or audio playing on your PC. This was how I came to know about this great feature of Audacity. It can record any sound playing on your computer. Yes, its true recording any type of sound(live streams, youtube etc.) is just a click away. In this article I will tell you how to do it.
I have tried this on Ubuntu 9.04 using the audacity available in the repos. It will be almost same for all the Distros.
If you are Debian or Ubuntu user then either click this link or enter this command to install Audacity.
[shredder12]$ sudo apt-get install audacity
If you are using Fedora or Red Hat then run this command.
[shredder12]$ su -c 'yum install audacity'
Open Audacity (Applications -> Sound and Audio -> Audacity). Go to Edit-> Preferences -> Audio I/O. Now, select "alsa:default" for the playback device dropdown box and "alsa <audio_hardware_ID> hw(0,0)" in the recording device drob down box.
It should look something like this.
After this you will have to configure the sound capture settings in your system. Enter the command alsamixer in your terminal.
You will see a window similar to the following.
After you can see that this is the [playback] mode. Press tab to shift to the [capture] mode. And the window will show you the different capture devices. It should look similar to this.
Now, select the capture device by pressing the space bar. A red capture (CAPTUR) should appear under it. The red capture means that the device is activated now (or turned on). A "------" means that the device is turned off. Set the volume of the capture device to a high value(you may adjust it later).
If you have other devices like "mix" or "master" then select one of them too. I can't exactly tell you which device to select but if you are having trouble while recording then you can select others later one by one to troubleshoot. But in most of the cases it will work without any problems.
Now, suppose you are playing a song on youtube, you liked the song and you want to record it. Then open audacity, and click the record button. Assuming that you have done all the config mentioned above Audacity should start recording the sound going through the /dev/dsp device (raw sound). So, if you want a clean recording then try to turn off all the system sounds otherwise those will get recorded too.
But in some systems the configuration given above might not be sufficient. I don't exactly know why but if you don't see other devices in capture mode (of alsamixer) then you will probably have trouble recording. This is not just applicable to Audacity you probably won't be able to record (this type of live audio recording) using any method.
On the other hand, if its working then you can record any kind of audio playing on your system. Audio from streaming audio/video, system sounds, live audio recording, you can even create your own mix by playing may songs simultaneously :) .