this space intentionally left blank

December 31, 2008

Filed under: music»recording»production

Don't Fear the ReaFIR

I don't really know how to say this, but: I forgot to get you anything for the holidays. I feel terrible, honestly. And after you got me such a lovely sweater.

(Belle! Take the sweater off the cat! She has some dignity to preserve!)

I'm sorry. Let me make it up to you. Here, have a peppermint stick and a quick tutorial on cheap noise reduction.

There are two cardinal sins of audio that I've committed, and which I've noticed in work by others, since it became easy to produce digital audio and video--by cardinal sins, I mean errors that make it instantly evident that this is not a professional production. The first is bad mike technique--having the microphone too far back, or too close, or using the wrong kind of microphone for the task at hand. The second is noise--noise from preamps, noise from wind and AC systems, or just the hum of a bad ambient environment.

The thing is, mike technique is hard. And you don't always have the option of great equipment, or the time to perfectly position it. You can't fix mike technique for free. And noise is also hard--I have noisy recordings all the time, because I use relatively dirty preamps with very quiet microphones, and I record in locations that aren't soundproofed (it is also likely that I'm simply not as good at this as I think I am). But constant and regular noise (such as that caused by a cheap preamp or a climate-control system) can be cleaned up (or at least, minimized), for free, after recording. And it gives us a chance to learn about DSP! Who doesn't love that?

Before going into the details of our signal processing, though, a disclaimer: sometimes simpler ways of dealing with noise are better. For example, rather than worry about filtering you could always just mask the noise with background music. Or you could use a noise gate, which would dip the volume when a person isn't talking. But I find that without music or something else to fill the spectrum, a gate can even make noise more noticable when the voice "pops" in from the silence. Besides, there are plenty of times when background music just doesn't match the desired mood, or when it's distracting. In this case, a slight amount of filtering combined with a gentle gate has produced very good results for me.

So let's say that we've got an interview recorded in a room with the AC fans running in the background, and on playback it doesn't sound great. What we're going to use to strip the white noise out of this audio clip is a Finite Impulse Response (FIR) filter. As might be obvious, this kind of filter is in contrast to an Infinite Impulse Response. Both work using the same basic principles, FIR just limits its scope a bit. Although the math for these filters quickly becomes complex, at its heart they rely on a very simple principle of weighted averages.

Remember that digital audio is represented as a series of numbers, each of which represents the value of a sample at a specific point of time. From sample to sample, sounds with high frequency content will show more change than those with little high frequency content, simply because the innate property of a high-frequency wave is its rapid change over time. So to filter out high frequencies, the easy approach is simply to generate a new wave, where each sample is the average of itself and the samples around it. That "smoothes out" the high frequency sounds, but leaves the low frequencies--which, after all, change much less from sample to sample--basically unaltered. Other kinds of EQ filters can be generated by altering the weights for each sample in the average.

What's really interesting about FIR is that you can combine it with a Fast Fourier Transform (also known as a FFT, which is a fascinating process for doing spectral analysis using math I don't completely understand) to determine the weighting for a desired filter curve. This is what the plugin we'll be using, ReaFIR, does to perform its noise reduction. Using the FFT analysis window, it takes a fingerprint of the noise we want to remove, and then sets up an filter to subtract that from the audio stream.

Let's see it in action, step by step:


click to view larger

  1. Add a ReaFIR instance to the track on which you want to perform noise reduction. Set the Mode pulldown to Subtract.
  2. Find a nice, long (1-4 seconds) of relative silence. We're going to use this to build the reduction fingerprint, so you want as pure a sample of noise by itself as possible. If there are any other sounds, they'll be incorporated into the fingerprint, and you may find yourself filtering out parts of the sound that you didn't want. This sounds really weird, and not usually in a good way.
  3. Check the "Automatically build noise profile" checkbox, and then using the DAW transport, play the clip you've picked for training. You should see yellow lines representing the frequency domain of the noise jumping across the display, with the red line (which represents the filter) fitting itself with the average of the yellow. Be sure to stop playback before you hit any voice or non-noise content. I often cut the noise out and move it to an isolated section at the end of the track, just in case I let it run too long by mistake.
  4. Now uncheck the "build noise profile" checkbox, and your filter is all set! If you play the track now, the noise should be magically gone, even during other sounds. You'll also probably hear a few artifacts, the most common of which is a slight whistling in the high frequencies due to resonance in the filter bands. I usually find that you can apply a gentle lowpass filter and tame this until it's unnoticeable.
This is really just the simplest trick that you can pull with ReaFIR, although it's the function I use most often. Another neat feature is to apply it as a mastering EQ (making sure to switch the mode from "subtract" to "EQ) after using the FFT to grab a fingerprint from a CD or a piece of music--it'll "clone" the sound of that track for your own, which works well if they're in the same style. An analysis EQ like this is a very useful tool to have around.

Well, I'm glad we got this sorted out. I'm sure you'll agree it's much better than a fruitcake, which was my backup gift. And just think: now that you've got this under control, we can celebrate the next holiday with an in-depth discussion of convolution reverb, which is based on many of the same principles. Why, maybe we could even start now...

Oh, you have to go? So soon? Ah, that's a shame, but if you must...? Then you must. I understand. Have a safe trip, then. And happy new year!

Future - Present - Past