The next step is to apply effects or filtering to modify the sound quality of your recording, if necessary. One situation where filtering might be useful is when capturing live audio from a microphone. Depending on the quality of the microphone and the acoustics of the recording space, you may need to perform frequency filtering or apply minor effects to give the recording a fuller sound.
Despite the precuations you may have taken setting the correct recording volume, sometimes an audio clip is just too quiet. If you've obtained the clip from somewhere else, you may have no choice in the matter. It's easy to use SOX to boost the volume level of the file. In fact, this can be done simultaneously with any other operation SOX supports. The first step is to find out how much the volume must be boosted:
$ sox mysong.wav -e stat
Maximum amplitude: 0.803
Minimum amplitude: 0.000
Mean amplitude: 0.006
Maximum delta: 0.690
Minimum delta: 0.000
Mean delta: 0.003
Volume adjustment: 1.245
The command runs some statistics on the samples in the file and prints the results. For us, the important one is the Volume adjustment suggestion. This indicates that we need to boost the volume about 24%. And we can immediately do this:
$ sox mysong.wav -v 1.245 newsong.wav
newsong.wav is created, with an optimal volume. This technique can also be used to soften the volume of an audio clip. Keep in mind, though, that if the recording volume was too high when the clip was recorded, lowering the volume of the file will not make the crackling go away. It will just be softer, like the rest of the file.
If graphical applications are your thing, you can use audacity to do exactly the same thing. The menu option is under Effect/Amplify. You also have the option of boosting the volume of certain sections, instead of applying the change to the entire file.
Frequency filtering is most familiar in the sense of a graphic equalizer. In the earlier section Types of Digital Audio, I discussed how frequency encoding converts an audio clip into a set of volumes. Frequency filtering is a mathematical operation that changes these volumes relative to one another. Figures 19-4 and 19-5 show a sample frequency encoding. The spikes you see are the pure tones with the highest volumes. Notice how, in Figure 19-5 , the lower-pitched frequencies are suppressed.
Although frequency filtering can be done very precisely, the human ear generally recognizes three broad categories: treble, midrange , and bass. Too much bass or too little treble leads to a "muffled" sound, whereas too much treble or too little bass leads to a "tinny" sound. The human voice generally falls in the lower end of the midrange frequencies, so vocals can be enhanced by boosting the midrange. Karaoke machines work by selectively filtering in the 2- to 4-KHz range while allowing other frequencies through.
Again, SOX excels at performing equalization. SOX provides low-pass, band-pass, and high-pass filters, which decrease the amount of treble, midrange, and bass, respectively. The filter called tape-deemph is also useful when recording directly from a television or DVD audio signal. All of these filters can be invoked during file format conversion. Consider the following commands:
$ sox infile.au tape-deemph outfile.wav
$ sox outfile.wav highp 4000 outfile-hp.wav
The first command performs a format conversion while applying the tape-deemph filter, and the second applies an additional high-pass filter centered at 4KHz and saves the recording into a new WAV file. SOX is restricted to one filter per invocation, but it supports pipes for input and output, so the previous pair of commands could be reduced to the following command line:
$ sox infile.au tape-deemph - sox - highp 4000 outfile-hp.wav
A word of caution: Many audio players for Linux, such as XMMS, have built-in graphic equalizers. If you are using one of these players to preview the "before" and "after" of frequency filtering, make sure that all the equalizer knobs are set to a central position. Otherwise, the "after" file that sounds best on your own system may not sound that good on someone else's system, defeating altogether the purpose of doing this kind of processing.
Sound effects are even more complex than frequency filtering; they include such well-known effects ( especially in electronic music) as reverberation , echo, delay, flanging, and chorus. The SOX utility can add all of these effects to any uncompressed sound file, using the same syntax as earlier:
$ sox mysong.wav -e reverb 1.0 500 250 mysong
Did I mention that audacity can apply effects to all or part of a file, as well? There's more than one way to do it in the Linux world.