How to prepare audio for online publication?
Audio files require post-processing before you prepare a web delivery version. First of all, the sound may need cutting, for example removing silence at the beginning and at the end of a recording. Besides the sound may require additional operations, such as normalizing, noise removal, etc. In this example you will see how to remove the silence at the beginning and at the end of the sound. We use the most popular audio editor – Audacity (http://audacity.sourceforge.net/). It is free, open source software available for Microsoft Windows, GNU/Linux, Mac OS X and other operating systems. You can download it here. In this example we will use the audio file in the WAV format with 24 bit depth and sample rate of 96 kHz and save the result of the processing keeping parameters of the original file.
Figure 1: Audacity main window with opened file.
Run Audacity. Open the file by dragging it into the program window or using the File-> Open... menu. The thin line at the beginning and end of the sound graph represents the silence. We can get rid of it in several ways. In this example we will first mark silence at the beginning of the sound and remove it and then select silence at the end and remove it.
Figure 2: Making a selection.
First, make sure the selection tool on the toolbar is selected. If not, click on it. Now press and hold the left mouse button and drag the mouse to mark the area with silence. You can extend and contract selection by holding down the Shift button and clicking on the area.
Note: Use and to zoom in and zoom out. After you select silence, remove it using the Edit-> Delete menu or by using Ctrl+K key combination. To see all the sound, press the (Fit project in window). In the same way remove silence at the end of the sound.
Figure 3: Audacity preferences.
Sound is post-processed but before you save it you have to change WAV format preferences. To do this, open the Audacity Preferences window by using the Edit-> Preferences... menu or by using the Ctrl+P key combination. Select File Format tab and Other... from the Uncompressed Export Format list. To save a file in a WAV format with 24 bits depth select WAV (Microsoft) as Header and Signed 24 bit PCM in Encoding. Finally save the file using the File-> Export as WAV... menu.
How to convert digital audio files?
In the previous paragraph we adjusted an audio file by removing fragments from the beginning and the end. This archive version will be used to prepare a web delivery version in mp3 format by using the LAME encoder. As you can read at the LAME home page, „LAME is a high quality MPEG Audio Layer III (MP3) encoder licensed under the LGPL.” LAME is distributed as a command line tool. In addition to a console tool LAME is supported by many programs, usually with a graphic user interface. A complete list of software which supports or uses LAME can be found here. Find and install the version appropriate for your operating system. In this description we use Windows binaries for version 3.98.4 downloaded from RareWares.
Before you start conversion to the mp3 format, here is the basic information about the mp3 encoding modes:
- Constant Bitrate (CBR) – default encoding mode, bitrate is the same for the whole file, useful for streaming, not optimal for storage
- Average Bitrate (ABR) – average amount of data per second, higher bitrate for the parts that needs more bits, higher quality than CBR
- Variable Bitrate (VBR) – bitrate varies depending on the requirement, preferred for storage
Open a command prompt and run the lame — help command to display help. If the command is not available, navigate to the directory where the program lame is located. This is the lame command syntax:
lame [options] <infile> [outfile]
[options] - encoding options, they are not required
<infile> - the path to the input file to convert, this parameter is required
[outfile] - output file name. If you do not specify it, the output file name will be created by adding .mp3 extension to input file name.
In the following examples we use the WAV file (I-iv-011.wav) with 24-bit depth and sample rate of 96 KHz.
Start by running the lame command specifying only the input file name as parameter.
Below there is the result of this command with an explanation of important messages.
LAME 3.98.4 32bits (http://www.mp3dev.org/) <- name and version of the codec
CPU features: MMX (ASM used), SSE (ASM used), SSE2
Resampling: input 96 kHz output 48 kHz <- output file attributes
Using polyphase lowpass filter, transition band: 16452 Hz - 17032 Hz
Encoding I-iv-011.wav to I-iv-011.wav.mp3 <- input and output file name
Encoding as 48 kHz j-stereo MPEG-1 Layer III (12x) 128 kbps qval=3 <- compression options
Frame | CPU time/estim | REAL time/estim | play/CPU | ETA <- processing time statistics
7008/7008 (100%)| 0:08/ 0:08| 0:08/ 0:08| 19.935x| 0:00
kbps LR MS % long switch short %
128.0 1.7 98.3 99.8 0.1 0.1
Writing LAME Tag...done
As you can see above, by default, LAME uses constant bit rate of 128kbps with 48kHz sample rate. For a given bit rate, we have a choice of internal algorithm quality by using -q nparameter, where n ranges from 0 to 9. 0 gives slowest algorithms, but potentially highest quality, 9 gives faster algorithms, very poor quality. Additional parameter -h is same as -q2 and-f is same as -q7. Parameter -h is recommended. As you can see, default encoding uses quality setting equal 3. To convert with higher quality, but a little slower run:
lame -h I-iv-011.wav
To use fast mode, but with lower quality run:
lame -f I-iv-011.wav
In CBR encoding use -b n option to set bit rate, where n can be 8, 16, 24, ..., 320.
To encore with VBR use -V n parameter which specify VBR quality setting, where n ranges from 0 to 9 (0=highest quality, 9=lowest, default=4). Run command
lame -h -V 6 I-iv-011.wav
to create mp3 audio file with variable bit rate.