A Hum Filter

This software demonstrates a comb filter for Pentium PCs which have an OSS API to a full duplex sound card.

The filter is intended for use when listening to VLF radio signals in the presence of foreground or background hum.

The program features:

See http://abelian.org/humfilt/ for the latest version of this package.

This filter copies the sound card input to the output, tenaciously following the line frequency hum with a deep notch. When properly set up, the harmonic components of foreground hum should almost all the time be completely inaudible at 16 bits dynamic range.

Anyone is welcome to do what they want with this code. You will most likely want to use this program to try out the filter, and then import the filter functions into your own software.


Comb filtering is very effective at removing the harmonic components of line frequency interference. By subtracting a delayed version of the signal from the original, any incoming frequencies which are periodic in the delay time are completely notched out. The frequency width of the notches is fairly wide and produces a noticeable drainpipe effect on the sound. By combining the output of multiple delay stages, this effect is considerably reduced and a much more natural sound is produced.

Sharpness of the multiple stage notch necessitates accurate tracking of the varying line frequency (typically wandering by up to +/- 0.5%) to ensure that the line harmonics remain in the deepest point of the notches. This can be done by using the delay buffer and summing function to generate a 3-point periodgram, which is used to steer the delay time towards that which gives maximum output from the summing function, and therefore the deepest notch.

The depth of the notches and the tightness of the period lock enable the harmonic components of foreground hum to be removed almost completely. The program uses linear interpolation when drawing samples from the delay buffer, which improves the accuracy of the notch for those delay times which are not represented by an integer number of samples.

Caveats and Tips

In no particular order:

CPU Consumption

The following figures give the percentage utilisation of a single 450Mhz P2 processor, at various settings of the filter.
  samples/sec    stages     usage

     8018            2        2%
    18092            2        5%
    50400            2       16%
     8018            4        4%
    18092            4        9%
    50400            4       26%
     8018            6        6% 
    18092            6       13%
    50400            6       38%

     8018           10       11%
    18092           10       21%
    50400           10       57%


For unix and linux, download the tar file humfilt-1.3.tar and unpack.

If you have 60Hz line frequency, edit humfilt.c and change NOMINAL_DELAY from 20.0 to 16.6666. If your sound device is not /dev/dsp then edit the value of DEVICE. The other default settings should be fine as they are for most situations.

On Linux systems, compile the program with,

  cd humfilt-1.3
On other systems, you may need to alter the header files in humfilt.c to suit your local conventions.

Running the program

Start the filter with the command
   ./humfilt -16 -r 18092 -s 4
This will set the soundcard to 16 bits, with 18092 samples/sec, and will run a 4 stage filter. The soundcard input (as determined by the mixer) is copied to the line output and filtered along the way. The program prints out status information each time it revises the delay time. This includes a peak input value, in the range 0 to 1, which should be used to set the mixer input level.

The program may take a few seconds to lock onto the hum.

The full set of command line options are:

The default values are 16 bits, 18000 samples/sec, and 4 stages, with the delay revised every second. The soundcard will be set to the nearest value supported by the card.

The filter can be switched in and out by signalling the program. To turn the filter off, use

  killall -USR1 humfilt
and turn it back on with
  killall -USR2 humfilt
The filter continues to maintain its track on the incoming hum while it is switched out.

My Experiences

When the claustrophobic foreground hum ebbs away as the filter locks in, a delightfully spacious background of VLF signals emerges. Very comfortable to listen to. Not even the faintest trace of hum, despite the hum being 10 times the amplitude of the VLF activity. This filter allows me to monitor the VLF band full time from home. In fact I now get much better reception from home than I've ever achieved by hiking out into the hills. Sounds great played through the big stereo in the living room!

Some example VLF sounds which have passed through this filter are:

Maintainer Paul Nicholson, vlf0308@abelian.org.