Audio Loopback Recording With PulseAudio
It is possible in Ubuntu, and other Linux distributions that use pulseaudio, to redirect sound that is played to a virtual input device. You can use this to record sound directly from your system without capturing any background noise that your microphone would pick up, and without losing nearly as much audio quality.
The first pre-requisite is that you have Pulseaudio installed. In newer versions of Ubuntu, this is already taken care of by default. If you are using an older version of Ubuntu (7.10 and earlier), then you can see how to set up pulseaudio at this wiki page: https://wiki.ubuntu.com/PulseAudio
Open Synaptic, or the Ubuntu Software Center, and search for and install the Pulse Audio Volume Control program called "pavucontrol". You can also click on this apt link to do so: apt://pavucontrol
Once you have it installed, you can now use it to re-direct your audio. It should be listed in your applications menu as "PulseAudio Volume Control". Go ahead and open it.
We now have to do a test-run before we can begin using it. Open the software you wish to record the audio with, and start recording. By default it will probably start capturing from your microphone, which is why this just a test run.
Now switch over to PulseAudio volume control, and on the 2nd tab labeled "Recording", you should see your application recording, and if it's picking anything up you may see a bar jumping. If you're certain your application is recording properly, but isn't displayed here, try changing the dropdown box in the bottom right of PulseAudio Volume Control from "Applications" to "All Streams".
You'll now see in the top right of the recording settings for your application a button that lists the device it is currently recording from. Click this button and change it to "Monitor of foo" where "foo" is the name of your sound card that is playing the audio you wish to record. In my case it reads "Monitor of Built in Audio Analog Stereo".
You can now stop recording, and even though the recording application is no longer recording, pavucontrol will remember to make that program record on the sound monitor until you change it back to something else using the same method described above. I suggest keeping your system volume turned all the way up, and using the knobs on your speakers to adjust playback volume. This will help improve the volume and quality at which the audio is recorded.