Hack 34. Edit Audio with Audacity
Record, crop, rearrange, and save audio with the cross-platform Audacity tool.
Often when you take a picture or write a paper, the first effort isn't perfect. Usually there are changes you need to make, whether cropping pictures or changing wording, before everything is perfect. Recorded audio is often the same. There are often periods of silence you need to remove from your recording, mistakes you need to edit, or other changes to make before the track is how you want it. Another more recent use of audio editing is podcasting, or the process of creating audio content that you then share and link to with RSS feeds so people can listen at their leisure. [Hacks #86 and #87] discuss podcast programs under Linux, or you could reference O'Reilly's Podcasting Hacks for more detailed information. Whatever your reason for editing audio, one particularly useful tool for performing these kinds of edits is Audacity.
Audacity is a cross-platform audio-editing program that runs on Linux, Windows, and Mac platforms. It is popular enough that you will likely be able to find a package for it for your distribution, but if not, you can download the latest release from the official web site at http://audacity.sourceforge.net. When you run Audacity for the first time, the interface that appears might seem a bit intimidating if you haven't worked with audio-editing software before. Audacity has a lot of powerful features that could take many pages to describe, but for the purposes of this hack I am going to cover only some of the basics: recording, editing, and cropping sound.
2.23.1. Record Sound
Audacity can accept input from a variety of sources, including previously created sound files, saved Audacity projects, and microphone input. There are a few initial steps to perform to set up audacity to record from your microphone. First, open your mixer program of choice and make sure that the microphone is not muted and that the microphone itself is at a reasonable volume. Next, locate the volume slider near the top of the Audacity window that has the picture of a microphone near it and make sure that it is at a reasonable volume as well. The exact volume levels for your microphone will depend on a variety of factors including what you are recording and what microphone source you use, so you might have to experiment to find the most suitable levels. To the left of the microphone slider is a drop-down menu that lets you choose from a number of audio sources including Vol, Line, CD, Mic, and other options. Make sure that this menu is set to Mic.
Once all of your volume levels are set, click the Record button (the button near the top that has a red circle as its icon) to start recording. When you are ready to stop recording, click the Stop button (a few buttons to the left of the record button represented by an orange square) or the Pause button to pause the recording. Audacity will show you the audio track live as it is being generated in the lower part of the window. To listen to your recording, click the Play button to the left of the Record button. To listen to a particular portion of the recording, just click on that section of the track and then click Play. Once you stop a recording, if you click the Record button again Audacity starts with a new track.
2.23.2. Edit and Crop Sound
Audacity makes the process of editing or cropping an audio track pretty simple. To edit a particular audio file you have previously created, click File Open and choose the file to edit. Audacity can edit WAV, MP3s, and Ogg Vorbis files alike. To remove a section of audio from the track, click and highlight that particular section with your mouse. If you click Play at this point, Audacity will play only the portion you have selected, which can be useful to isolate exactly what you want to remove. Click Edit Delete to remove the selected section. You can also move around sections of the audio with Cut and Paste operations. Just select the section of audio to move, and click Edit Cut. Then click where you would like to paste and click Edit Paste. If you would like to crop a particular section so only it remains, select it and click Edit Trim. In between sections of a recording, you might notice that the microphone has picked up background noise that you would like to remove. Select the section you would like to silence, and then click Edit Silence. Audacity will replace the section with complete silence.
2.23.3. Save Changes
When you are ready to save a project, close any unwanted tracks you may have been working from so that only the tracks you want are left behind. If you want to remember each of the tracks and resume the project at a later date, click File Save Project As to save the entire project. To export to an audio file, click File Export as WAV, File Export as MP3, or File Export as OGG to export to WAV, MP3, or Ogg Vorbis formats, respectively.