Remove mains hum

I have been recording an audio book with four actors around a single microphone. I will add sound effects later.

The setup was very simple and almost guaranteed to give poor results: a cheap electret microphone with a plugged into the onboard sound card of a laptop using a 5m cable.

During my initial tests, everything sounded OK: hiss was acceptable and frequency range was good. I could not hear the low frequencies, though, because of the terrible speakers in the laptop. I should have listened properly…

After all of the recording was completed, I connected up to the stereo and heard…obnoxiously load main hum.

The noise removal tool in audacity v 1.2.something did a good job at recognising the noise, but gave a hollow sound if I turned up the effect enough to remove the hum. Perhaps v1.3 would do better…

The notch filter set to 50Hz did not remove the hum properly unless it was very wide, which also removed much of the bass.

The low pass filter was only really effective if set to 400 Hz or so.

The spectrum analyzer over a period of silence showed that there were peaks at 50 Hz, 100 Hz, 150 Hz and so on, up to 300 Hz before they vanished into the noise. I assume that the mains hum was badly clipped and distorted to give all these harmonics.

Then the solution became obvious: I needed notches at 50 Hz and all multiples up to 300 Hz. I looked at the source code for the Notch filter in notch.ny, and worked out how to make the necessary changes to make very narrow notches at the frequencies I wanted, with the attenuation I needed at each frequency.

It worked like a charm, although it did cut down on the bass slightly. A little bit of Bass boost put the man back into the men’s voices.

Lessons learned:

  • listen to your setup before you do hours of recording
  • they invented microphone preamps and balanced connections for a reason
  • audacity had the tools to identify the problem (spectrum analyser) and to solve it
  • nyquist is Lisp. It is different from C, Java and Python, but succumbs to reason like any other programming language

Thanks for the great program.

Good work.

I have one small point to mention. Mains hum naturally has a number of harmonics, it’s not a perfect sine wave. So your mains hum wasn’t distorted.