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:
http://abelian.org/humfilt/ for the latest version of this package.
- Multiple delay stages to obtain a very sharp notch which
reduces audible coloration of the signal.
- Period space tracking of the line frequency, which accurately maintains the
harmonics in the deepest point of the notch.
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
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:
Delay tracking doesn't work for less than two stages.
This type of filtering will only remove harmonic components of the foreground
hum. Non-harmonic components can be a real problem, especially with signals
from H-field antennas. Other techniques must be used to deal with these.
It is vital to ensure that foreground hum does not clip anywhere in the
receive path upstream of the soundcard, and that the soundcard mixer gain
setting is such that the signal does not go out of range on the A/D.
The program reports the peak input level so that you can monitor this.
If overloading is allowed to occur, the hum cross modulates with the noise to
produce a broad spectrum of interference which cannot be removed.
When dealing with foreground hum, 16 bit mode is preferable. If using 8 bit
mode and the hum is 10 times louder than the signals, the remaining dynamic
range after filtering is only 5 bits worth.
For simplicity, the program makes no attempt to customise the buffering on the
soundcard i/o. As a consequence, there may be a considerable time delay
between input and output.
In the event that the input hum is so weak that the filter can't recognise it,
it will probably slew to one of its end stops and sit there harmlessly.
When running with 10 or more stages, the filter can lock onto one of the dips
in the passband ripple. This occurs if the filter is started from cold and
the line frequency happens to be a long way from its nominal value. Usually
after a few seconds the filter finds the correct notch.
The ultimate depth of the notch is determined by the accuracy with which the
outputs of the delay stages can be summed, which improves with increasing
sample rate and increasing number of stages.
There isn't much audible benefit in going beyond 4 or 5 stages.
This filter is intended to improve the audible quality when listening to VLF
signals. It generates quite a bit of passband ripple which can sometimes be
a nuisance when taking signal measurements. For example when receiving ELF
signals below the line frequency, a straightforward notch filter for the line
frequency together with a low pass filter for the harmonics is likely to be
much more satisfactory.
This demo program as it stands, only works on Pentium processors when running
with 16 bit samples. Users of big endian machines will have to alter the code
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
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,
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.
- -8 Run in 8 bit mode.
- -16 Run in 16 bit mode.
- -r rate Try to set rate samples per second.
- -t cycle Revise the filter delay every cycle
- -s stages Use stages number of delay sections.
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.
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:
- aur.100203a.mp3, 390kB, 100 seconds. Auroral 'dawn chorus', present to some extent about
1 morning in every 5 or 6 at my 54 deg north location. Sometimes present in
the afternoons and evenings.
- sigs.110203.mp3, 155kB, 40 seconds. Background activity during the late afternoon.
Very few sferics and a couple of
auroral risers can be heard. There is also some non-harmonic power line
interference. I switched the hum filter out for a few seconds during this
sample to demonstrate the raw signal.
Maintainer Paul Nicholson, firstname.lastname@example.org.