Recording audio playing on the computer
From Audacity Wiki
| This page presents solutions on Windows, Mac and Linux to recording audio playing on the computer (such as internet radio), using Audacity and other alternatives.
|
Note: Generally, it is not the best policy to convert audio files to different formats or extract audio from CDs and DVDs by recording them as they play. Recording off the sound card is a relatively inexact and lossy process, because it usually involves converting a digital source to analogue in order to play it, then back to digital when it enters the recording software. The quality of the result will depend amongst other things on the quality of your sound card's digital to analogue and analogue to digital converters.
To extract audio from CDs to your computer, see How to import CDs. |
Contents |
[edit] Windows
Quick answer: use the appropriate "stereo mix" or similar input source on the Audacity Mixer Toolbar dropdown selector. Note: on Windows Vista and Windows 7, you must choose the appropriate Recording Device at Edit > Preferences > Audio I/O (or Edit > Preferences > Devices in the current Beta version). If you have problems, use the Windows Control Panel to enable and select the correct source or device - see especially the green panel "HELP ON RECORDING COMPUTER PLAYBACK OR STREAMING AUDIO" in that section. Also see this topic on the Audacity Forum.
[edit] Mac
Macs have no ability to record streaming as it plays on the built-in sound device. It is possible to record streaming audio from the built-in microphone, but this a very lossy method that also picks up all ambient noise.
Recommended solutions:
- If your machine has a line-in, you may be able to record audio from the computer into Audacity by joining the line-out and line-in ports on the computer with an audio cable, and setting the default input in Apple Audio MIDI Setup to line-in. To hear the sound while recording, use a single to double stereo connector to give you a jack for the speakers or headphones. This has two disadvantages: system sounds and unwanted sounds from other programs are captured in the recording, and minor degradation is likely because the digital original is converted to analogue by being played on the sound device. There is no conversion to analogue with the remaining three alternatives below.
- On OS X 10.4 or later, use Audio Hijack or Wiretap to capture the audio to AIFF files directly from the player application. Turn off compression in Wiretap Preferences if you want to import the recorded AIFF files into Audacity.
- On OS X 10.2 or later, use the free open source Soundflower system extension. Soundflower behaves like an additional system audio device, so for example to record streaming audio into Audacity you would select Soundflower as the output device in the application in which you are playing sound, and Soundflower as the input device on the Audio I/O tab of Audacity Preferences (Devices tab in current Audacity Beta). If the application playing the sound does not allow you to specify its output device, you can make Soundflower the default output device in Apple Audio-MIDI Setup.
- If you are playing an unprotected audio stream and know its actual web address, VLC player can save it to the hard drive in a number of formats including WAV, MOV and OGG. QuickTime may also be able to save at least unprotected MP3 streams as MP3 or MOV.
- There is another software you can used called Sound Tap from NHC
[edit] Linux
On Linux there are in general two different sound systems that provide drivers to your sound device, OSS and the more recent ALSA. Additionally, advanced sound servers such as JACK can use ALSA as a backend to provide professional quality audio.
[edit] ALSA
[edit] Alsamixer
To record computer playback into Audacity, you can use the alsamixer mixer device to select the "capture" device of your sound card and adjust its input volume. Alsamixer should be already installed. Alsamixer is a command line tool, but with "view" options to represent the sound device graphically.
To start alsamixer, open a shell/terminal and start the program by typing alsamixer. There are three different views: Playback (default), Capture and All. This is the Playback view, which you can get to at any time by pressing tab or F3 :
Top left you should see some information about your sound card. Below are volume bars for adjusting the output volume for each named device: examples are Master, PCM, Line, CD and so on. The currently selected item appears in red and the volume percentages are displayed for left and right channels above the device name. For a mono device, only one value is shown.
You can scroll between devices using the left/right arrow keys. Use up/down arrow keys to adjust the volume. Press the M key to mute/unmute the device. When a device is turned off, M (mute) appears below the volume bar. When it's turned on, O in green appears instead.
Now press the tab key or F4 to switch to Capture view. This is preferable to switching to All view with Enter, because All may not show all of the capture devices for your card.
Select the device called Capture with the spacebar. The red CAPTUR flag should appear underneath the Capture bar to indicate that capture is turned on for that device, and L and R letters will indicate that left and right channels are turned on. Devices whose capture is turned off are shown by ------. Now, also select the "Mix" device (this might sometimes be called "Master").
Launch Audacity and open the preferences using CTRL + P or navigate to it by clicking Edit > Preferences > Audio I/O tab. Select Alsa: default as playback device and Alsa:<Vendor ID>:<Vendor ID> (hw:0,0) as recording device ("0" represents the default sound card). Click OK to exit Preferences, then press the red Record button or the R shortcut to start recording the audio playing on the computer. If the audio is too soft or too loud so it distorts, you will need to check both the output levels in the Playback view of alsamixer, and adjust the recording level in Audacity (or do so in the Capture view of alsamixer).
If no capture device is available, try plugging your line-out or headphones-out to the line-in and then record from line-in. To hear the sound while recording, use a single to double stereo connector to give you a jack for the speakers or headphones.
If you have only mic-in and no line-in is selectable through alsamixer, you can build an attenuator to reduce the line level output to a level suitable for mic-in. But probably this will only provide mono recording, because mic-in is mono in most cases. As well, the quality may be questionable.
[edit] Using the ALSA PCM file
It is not necessary to use Audacity to record sounds playing on the computer. You can capture the sound from the application producing it before it reaches the sound device. So this solution can be used even if there is no sound device.
First you need to create (or edit if it exists) ~/.asoundrc file. Do it with your favorite plain text editor. Note: ~ is your home directory so change that to /home/john or whatever if you are not working in a Linux shell.
pcm.teeraw {
type empty
slave.pcm "tee:default,'/tmp/out.raw',raw"
# 48000 S16_LE 2ch (aplay -t raw -f dat)
}
Now tell the application you are trying to record from to use the "teeraw" ALSA device for playback - read the application's manual for help. Run the application. Stop the application. Now /tmp/out.raw should contain your sound with perfect quality. If you change "default" to "null" in the above text, you will not hear anything but sound will still go to the file. If for some reason "empty" is not liked by your ALSA library, then try with "copy".
If you want to record all sounds played through the computer, you'll need to set the teeraw device as your default device with something like:
pcm.!default{
type empty
slave.pcm "teeraw"
}
In this case though, you will need to change "default" to "null" or something else because that will be the default device. In many cases "dmix" should do it. Note that you'll pick up random sounds from other applications such as system "dings", and the raw file could get corrupted or overwritten.
With newer ALSA versions you can try these parameters for convenience and play with different programs:
pcm.teewav {
type copy
slave.pcm "tee:default,'/tmp/out.raw',wav"
}
pcm.teemp3 {
type file
format "raw"
slave.pcm "default"
file '|/usr/local/bin/lame -S -r -s %r --bitwidth %b -m j - /tmp/asound-$$.mp3'
}



