To be clear I'm not trying to eleminate mains hum from my shoddy equipment. I'm deliberately using large coils of wire to pick up RF which by their very nature are going to pick up mains hum too. I'm interested in the frequencies near mains hum, but the hum itself is a bit tedious, so I want to filter it out.
(electricitree ->)
I tried creating a notch filter using a LowPass and HighPass filter in parallel and then scripted creating a set of these in series at odd harmonics of mains hum (here in the UK that's 50Hz, 150Hz, 250Hz, 350Hz). It kind of works but to get a reasonable notch I've used filters of order 20.
the script in case you're interested:
"Assemble a set of notch filters"
| input |
input := mic.
(1 to: 9 by: 2) do: [:i |
input := notchFilter notchFrequency: (50 * i) Q: (!Q * 50 * (i sqrt)) filterOrder: 20 notchInput: input.
].
notchFilter start: 0 s.
I was imagining people would have come across this problem before and might have much better ideas?
Above is an image of normal mains hum (me sitting in a chair wired up to the sound card).
And above is the spectrum analysis taken at the same time. (The first peak is about 50Hz, the other big peak is around 250Hz).
...and here is the hum when hugging the tree. The tree acts as a big hum antenna. The signal looks a bit different from the pure hum inside the house.