pts' Linux audio recording tutorial ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ by pts@fazekas.hu at Tue Aug 1 15:50:30 CEST 2006 This short tutorial describes how to record audio from a sound card to MP3 under Linux with noise reduction and volume normalization. Definitions: -- real time: the time needed to play the WAV file in original speed Software needed: -- Linux -- wavrp: for recording the WAV file Download it from http://www.inf.bme.hu/~pts/wavrp-latest.tar.gz -- aumix: for adjusting the volume -- normalize: for normalizing the volume -- audacity: for removing noise and cutting the silent beginning and end audacity is a GTK X11 application. -- lame: for WAV -> MP3 encoding and resampling -- wawfix.pl: (optional) for fixing headers of partially recorded WAV files Get it from http://www.inf.bme.hu/~pts/ Why not use an integrated GUI application for recording? Because I wasn't able to find an all-in-one solution that does proper noise reduction (like audacity), volume normalization (like audacity or normalize) and MP3 encoding (like lame -- audacity is too dumb: advanced MP3 encoding options cannot be specified). Howto ~~~~~ Time measurements below were taken with an 2400 MHz Intel Celeron. Plug stereo input cable to ``line in'' input to the sound card Use the ALSA kernel modules (with OSS emulation) to access the soundcard. This is because ALSA is full duplex, i.e. you can record a WAV file and play (process) another one simultaneously. You need the snd_pcm_oss module (and not i810_audio ac97_codec). Example commands: $ rmmod i810_audio # Dat: replace with your OSS driver module $ rmmod ac97_codec # Dat: replace with your OSS driver helper module $ modprobe snd-intel8x0 # Dat: replace with your ALSA driver module $ modprobe snd-mixer-oss $ modprobe snd-pcm-oss $ modprobe snd-seq-oss $ modprobe snd-seq-midi-event $ modprobe snd-seq $ modprobe snd-seq-device $ modprobe snd-timer $ aumix -v100 -c0 -i64 -l64 -m0 -o0 -s0 -t0 -x0 -10 -20 -30 -lR $ wavrp -s l -f foo.wav This starts recording in CD quality: 44100 Hz, 16 bits, stereo. Recording takes real time to record. Be quick to do the next action as soon as possible. Start generating signals to your computer's line in, i.e. press Play on your source equipment, or start singing into the microphone etc. Wait for the recording to finish. Listen to the audio when necessary. Press Ctrl- when finished recording. WAV header will be updated. $ cp foo.wav ina.wav Play back foo.wav (i.e. `wavrp --play foo.wav'). If it is way too loud or quiet, adjust the IGain with aumix, and re-record: $ aumix -i40 # if too loud, decrease from 64 to 40 $ aumix -i80 # if too quiet, increase from 64 to 80 Find the proper IGain value for each recording. $ audacity File / Open ina.wav This takes about 1/140 real time. Zoom, select noise at the beginning or end. The longer, the better. 10 seconds should be enough. If you've recorded stereo, but one of the channels is muted, remove that channel. To do this, first (double-) click on the lower-pointing triangle in top left of the track window to get the track menu. Then split the track, delete one of the resulting tracks, and change the type of the other track to mono (do it from the track menu). Effects / Noise removal / Get noise profile Ctrl- (select all) Effects / Noise removal / Remove noise This is slow, this takes about 1/8 real time. Cut start and end (use to find zero points). File / Export to WAV inaa.wav This takes about 1/35 real time. Don't save the project in audacity. Saving the project is slow and creates tons of auxilary files. You might try GWC (http://gwc.soureforge.net/) to remove noise. But it didn't work for me: it changed the WAV file, but the noise still remained. $ rm -rf ina_* _norm* noise.dat # audacity temp? $ normalize inaa.wav $ lame --vbr-new --resample 22050 -b 64 -h -m m inaa.wav inaa.mp3 These MP3 encoding settings are suitable for speach. Try this instead for good quality music: lame --preset hifi inaa.wav inaa.mp3 This takes about 1/30 real time. Use command line options to add meta-information (artist, title, album, year etc.) as ID3 tags. lame can resamle audio and downmix it to mono. $ mv inaa.mp3 foo.mp3 $ rm inaa.wav Output files: -- foo.wav: original audio file, as recorded from the sound card -- foo.mp3: final MP3: small, noise reduced, volume normalized Diagnostics ~~~~~~~~~~~ D1. I cannot hear the music to be recorded on the computer """""""""""""""""""""""""""""""""""""""""""""""""""""""""" Make sure that you put an input signal to the cable connecting your source equipment to your computer. Make sure your cable works (both left and right channels). Make sure that the cable is connected to your sound card's ``line in'' input socket. Make sure that both ends of the cable are connected properly. Make sure can listen to music on your computer. Try playing an MP3 file and make sure you can hear it. Increase the ``line in volume'', i.e. try one of $ aumix -l100 $ aumix -l64 Increase the output volumes, i.e. try one of $ aumix -v100 -w100 $ aumix -v64 -v64 D2. Silence gets recorded """"""""""""""""""""""""" Make sure you have solved D1. Increase the ``input gain'' (IGain) volume, i.e. try one of $ aumix -i100 $ aumix -i64 Re-record. If the problem is solved, you can mute the ``line in volume'' if you don't wish to hear the audio while being recorded. Do this: $ aumix -l0 D3. Audio tools cannot load my partially recorded WAV file """""""""""""""""""""""""""""""""""""""""""""""""""""""""" Use wavfix.pl to fix the WAV file: $ wavfix.pl file.wav __END__