Wednesday, February 11, 2009

Tidbit: Recording The Soundcard Output

I have been looking for a couple of days for a way to record the output of my speakers directly to a file i.e. record what I hear. An easy good quality solution was one I found here. Since I modified it slightly to suit my own system, I thought I'd document it both for myself and others.

I am using an Ubuntu Itrepid based system which has been modified to use ALSA as the sound architecture. This is in fact the pre-release Beta of Linux Mint Fluxbox CE.

This is what I did:

1) Edit /etc/asound.conf and added the following at the end. This creates a device which copies another.

# copy device for output recording
pcm.copy {
type plug
slave {
pcm hw
route_policy copy

2) Restart ASLA with:

sudo /etc/init.d/alsa-utils restart

3) Get the 'numid' of the 'Capture Source' and the Item number of the 'Mix' device (you will have to go through the long output)

amixer contents

The part you are looking for looks something like this:

numid=22,iface=MIXER,name='Capture Source'
; type=ENUMERATED,access=rw------,values=2,items=8
; Item #0 'Mic'
; Item #1 'CD'
; Item #2 'Video'
; Item #3 'Aux'
; Item #4 'Line'
; Item #5 'Mix'
; Item #6 'Mix Mono'
; Item #7 'Phone'

4)Then set the copy device to copy the 'Mix' device (5) by running this:

amixer cset numid=22,iface=MIXER 5

That's it!

When you are ready to record run this in the terminal

arecord -c 2 -f S16_LE -r 44100 -t wav -D copy foobar.wav

The output file will be a large wav file.

To encode it to a good quality mp3, run:

lame -V - foobar.wav


1 comment:

Anonymous said...

what the hell is this.....i thot your butt studied medicine!!!!!!!!hit me back on how is your your bro still in the is???