Hum removal

“Mains Hum” is a common problem. It is a hum with a base frequency of 50 Hz (Europe) or 60 Hz (US). Usually there are a lot of harmonics of the base frequency.

This can usually be effectively filtered out with notch filters, but in some cases may require dozens of notches to handle the audible harmonics.

We already have two “Hum Removal” filters on this forum. Either of them can produce good results, but I don’t think either of them are particularly user friendly and generally require a lot of trial and error to find settings that remove enough hum without affecting the remaining sound too badly.

It would be much easier if we had a real time effect, but that is likely to be a long way off, so I’m wondering what we can do to improve the tools so that they are effective and easier to use.

Any thoughts anyone?

Most times the performance hums because it doesn’t know the words.

Ba Dump. Tish!

Is this a good place to background connect Analyze > Spectrum to the notch generator?

Drag-select a portion of the show with hum only (if you have a large enough selection, it doesn’t even matter if there is a little performance in there, too).

“Cool. Let’s see. We’ll need a notch here. And one over there…”

Although I guess that’s what Noise Reduction, sorry, Removal does anyway, isn’t it?

Is there such a thing as “Standard Hum?” I can pick out open-shield 60Hz buzz in a line-up from across the street. It’s very distinctive – not at all start-from-zero random.

I think Sound Soap had Standard Hum Removal.
Yeah, here it is:

Remove Hum
[X] … 60
[] … 50
[
] … Off

Koz

Can I assume you can’t test for effectiveness? Do a recursive filter generation?
Take Out 180.
Test for 180.
Take more out.
Test…

If: No Change.
Then: take Out 360.

Koz

Taking out 50 / 60 Hz is easy. The problem is taking out the harmonics.
In some cases the “fundamental” (50 / 60) can be quite weak, but there still be a pronounced audible hum due to the harmonics.


Within limits, the hum is predictable.
If the hum is exactly 60, 120, 180, 240 … Hz, then extremely narrow notches can be used, which will leave the “music” virtually untouched, unless of course the music happens to hit one of those frequencies.
If the music does hit one of those frequencies, then not only does it get taken out, but it takes a few moments for the filter to “catch up”, and in those few moments it rings. Thus a broadband transient, such as a hand clap, does not just go “snap” it goes “ping…”

The amount of ringing can be reduced by using a wider notch, but that will take out a broader band of frequencies.

In practice the hum (after it has been recorded) will probably not be the exact frequencies expected. For a very narrow notch (say q=50) the attenuation at the centre frequency will be more than 100 dB, but as little as 0.1% off the centre the attenuation drops to 20dB. Unfortunately it is difficult to measure frequencies to that degree of accuracy, and if (as occurred recently) the original recording was made on tape, then the frequency will probably not be constant. At some point we have to give up and say it can’t be fixed, but within limits we can make compromises. The difficulty is in how to automate those compromises.



Yes and Yes.

Nyquist doesn’t have access to Audacity’s spectrum analyzer, but it could recursively test a noise sample and work it’s way up the harmonic progression until it makes no difference. That would be the “hum profile”.

Taking out 50 / 60 Hz is easy. The problem is taking out the harmonics.

I don’t think it’s just taking out the fundamental. Sound Soap’s reputation was that it could make things sound good. You can’t hear either 60 or 50. It could also derive a noise profile without the profile step. Whatever single sound is there the longest is probably the noise.

Nyquist doesn’t have access to Audacity’s spectrum analyzer, but it could recursively test a noise sample and work it’s way up the harmonic progression until it makes no difference. That would be the “hum profile”.

That’s the automated version right there. The fancy-pants® version sloppy tests for 50/60, then which 50 or 60 and then goes up.

I wouldn’t even have to be fast.

[Now sniffing your hum. This may take a while]

I still don’t think it’s all that random. I can listen that that buzz and tell you which Belden microphone cable and where the break is.

Koz

If the music does hit one of those frequencies, then not only does it get taken out, but it takes a few moments for the filter to “catch up”, and in those few moments it rings. Thus a broadband transient, such as a hand clap, does not just go “snap” it goes “ping…”

Air-juggling notch filter characteristics is not the only way to deal with this. Generate an equal but opposite phase tone.

In the US, the NTSC television color signal was clearly visible in the image and needed to be removed.

http://www.kozco.com/tech/ntsc/ntsc.html

In the bad old days, they used straight notch filters which worked, but they removed everything around the color (sorry, colour) and made the image muddy and soft – or left artifacts. Then somebody generated a way to phase cancel the color signal through delays and some TV Art Tricks. No bandpass problems, so all the crispness and fine detail came roaring back and it almost looked as good as PAL.

Koz

I use an unversal method, it works like magic, but I’m not sure if it’s not possible to automate it with Nyquist…

Here is the algorythm:

  1. make 2 duplicates of the sound file.
  2. invert the data of 1st copy.
  3. cut the low frequencies (main hum frequency) with notch filter or parametric EQ filter of the 2nd copy.
  4. mix & render the both copies, now we have the hum sound + some “useful” low frequencies (especially if it’s about drums) with inverted data.
  5. compress the “useful” sound to the maximum level of hum frequency (it appears clearly at some points), now we have the noise profile with inverted data.
  6. mix & render the noise profile with original sound file.

I’ve tried to reproduce that, but I must be doing something wrong because I always get worse results than just notch filtering.

These are the tracks I have at each step:
I have:
Step 1. The original track (unprocessed), and 2 copies of the original (unprocessed)
Step 2. An inverted copy, the original and an unprocessed copy of the original
Step 3. The original track, and inverted copy and a notch filtered copy.
Step 4. The original track and a mix made from the 2 copies.
Step 5. The original and the processed copy (compressed).
Step 6. A mix of the two tracks from step 5.
Is that correct?

3) cut the low frequencies (main hum frequency) with notch filter or parametric EQ filter of the 2nd copy.
Should I do that in Audacity with the Notch filter? What settings should I use?

5) compress the “useful” sound to the maximum level of hum frequency (it appears clearly at some points), now we have the noise profile with inverted data.
Exactly how do I do the “compression”? What effect and what settings?

Again to go briefly down the cancellation pathway, use a peak filter to isolate one of the evil frequencies, say 120Hz. The metaphor is do it to a copy of the show. Get the isolation so sharp that the sine wave is all that is left. Do it over time so chances of a musical performance at 120 Hz is very low.

Reverse the phase and add it to the show. This is the step where it may be necessary to generate an appropriate 120 Hz sine wave rather than depending on the filtered one from the copy of the show.

Only the precise waveshape of the sine will vanish from the show leaving all the rest of the show including musical tones around 120 Hz perfectly intact. There are no filter skirts, bandpass ripples, or other instabilities affecting the show because the process is exactly the opposite of how the hum got into the show in the beginning.

Koz

Obviously, you can cheat until your fingers bleed by creating an ideal hum show and watching what the filters do under various conditions. It may simply not be stable enough to derive a cancellation tone.

It could also be possible to create a 120Hz tone and wave it around changing phase and amplitude until the hum goes away.

Also obviously, if the damage is unstable or changes pitch, then you’re straight back to the notches.

Koz

There’s the first problem. Notch filters (in fact most filters) change the phase. Fortunately not in an unpredictable way, but still it complicates the task.




And this is the second problem.
Considering that there is capacitance, resistance and inductance in the power lines and analogue circuits, we don’t know the phase of the 120, 180, 240… Hz components. They are almost certainly not “in phase” with the 60 Hz fundamental.

Hi, Steve!
Here I have a ready example to illustrate what I do. The method removes the hiss noise, but it’s universal and works perfectly to remove hum or cut off any frequency. If we’d like to remove hum noise (with 60Hz main harmonic), we just need to change Parametric EQ settings to like f=60Hz/width=1,0/gain=-15dB.

Screenshot 1
We have the original drum loop with hiss noise and 2 copies: (1) drum loop with inverted data/phase and (2) drum loop processed with Parametric EQ, f=6000Hz/width=8,0/gain=-15dB. If we’d like to cut off “deeper”, we could apply the Parametric EQ with that settings again and again.


Screenshot 2
We mix & render the 2 copies of original audio file. Here I zoomed in vertically so we can see the hiss noise: check out the selection. In the beginning of the audio file we can see the “healthy” drum sound. Note, that after we mix & render the 2 copies, we have something like band pass at 6000Hz, extracted directly from the original sound file, but with inverted data/phase.

Screenshot 3
We compress the “Healthy” sound by hand with the envelope tool (I haven’t found a good compressor yet to do that automatically), then mix & render it with the original sound so that hiss noise (band-pass at 6000 Hz with inverted data/phase) subtracts from the original.

We compress the “Healthy” sound by hand

This may be a good time to remind everyone that our immediate goal is to find an effective technique that can be automated.

Remove Hum? Yes [_] No.

Koz

Hahaha, yeah! :slight_smile: I agree, Koz! :slight_smile: In the past I used to work in Sound Forge and there is an amazing “wave hammer” effect. It literally hammers the sound to the level I wish, so it was easy to “stamp” the “healthy” sound to the level of noise :slight_smile: I guess, It’s not so hard to re-create it in Nyquist :slight_smile:
Things look very simple (but it’s hard to automate them) :slight_smile: Music has dynamics. When there are loud sound regions, we feel like noise disappears. When the “healthy” sound gets below some treshold, then we experience the noise because the level of “healthy” sound is commensurable to the level of noise.

I did enjoy your manual method. In electronics training we had the phrase “desperation method.” It has to work and there’s no other way.

There is an existing tool, but it depends on manual filter juggling. The goal is, as above, to set a tool loose on the work and the tool automatically figures out where and configuration of the filters. That’s the old joke of, “We have an amazing new machine that can do this work for us. It’s called a computer.”

The ultimate goal or possibly option is to use the phase cancellation method. Properly done that doesn’t affect the music “behind” the hum at all, but it’s much stickier to make work.

Koz

Well… I’m here to share thoughts, ideas and experience. I wish I was, but I’m not a programmer… :unamused:

Maybe we could automate everything… We just need a good compressor to “hammer” the “healthy” sound (with attack/decay settings) to the level of the noise. I dunno if it’s possible to scan the samples (lets say 5-100) millisecond before the “healthy” sound appear (which is far louder) and get automatically the level of noise?

And here are the parameters:

  1. Hum frequency: (50 or 60 Hz + harmonics)
    We extract the noise with inverted phase directly from the original sound
  2. Noise threshold
    That’s the level we need to compress the healthy sound to
  3. Attack/decay settings for the compressor

Thought I’d post a link to what I did to remove hum:
https://forum.audacityteam.org/t/audacity-1-3-3-presonus-inspire-now-much-love/182/1