Help in the design of a filter FIR.

Thread Starter

GRVEN21

Joined Jul 21, 2025
9
In an community project, I was assigned to design an FIR filter that eliminate the 60 Hz hum and its harmonics present in a voice signal, without perceptibly degrading the quality or intelligibility of the conversation, while meeting the real-time constraints (latency and computational cost) typical of telephony and VoIP systems. and then implement it in Verilog. These are the requirements.


  • Sampling rate (Fs):
    • 8 kHz (narrowband telephony, useful band ≈ 300–3400 Hz)
    • 16 kHz (wideband telephony, useful band ≈ 50–7000 Hz)
  • Frequencies to suppress (notches):
    • 60 Hz (main hum)
    • Optional harmonics: 120 Hz, 180 Hz, 240 Hz, 300 Hz
  • Attenuation at each notch:
    • ≥ 50 dB at the center frequency of each harmonic
  • Stopband bandwidth (BW):
    • Approximately 10 Hz (example: 55–65 Hz for the 60 Hz notch)
    • Adjustable: narrower if the tone is very pure, wider if there is mains frequency drift
  • Passband ripple:
    • ≤ 0.5–1 dB in the useful voice band outside the notches
  • Maximum acceptable latency:
    • ≤ 10 ms for real-time conversation
    • If lower latency is required, IIR (biquad notch) is preferred over FIR
  • Phase / phase distortion:
    • FIR: linear phase, but requires very high order (hundreds or thousands of taps) → higher latency and computational cost
    • IIR (biquad notch): non-linear phase, but very efficient with practically zero latency
  • Resource usage:
    • IIR biquad: ~2–4 multiplications per sample per notch (very efficient)
    • Long FIR: tens to thousands of multiplications per sample (high CPU/memory cost)

But my questions are the following:

  • What are the steps I should follow to design the filter?
  • Are the requirements correct, taking into account the ideal behavior of the filter?
  • Is the window method acceptable to solve this problem?
 

Ian0

Joined Aug 7, 2020
13,097
For an FIR, the coefficient are the impulse response of the filter. So to filter 60Hz with a 16kHz sampling rate, it is going to take at minimum 266 coefficients. An IIR filter could do it with two.
 

MrAl

Joined Jun 17, 2014
13,667
In an community project, I was assigned to design an FIR filter that eliminate the 60 Hz hum and its harmonics present in a voice signal, without perceptibly degrading the quality or intelligibility of the conversation, while meeting the real-time constraints (latency and computational cost) typical of telephony and VoIP systems. and then implement it in Verilog. These are the requirements.


  • Sampling rate (Fs):
    • 8 kHz (narrowband telephony, useful band ≈ 300–3400 Hz)
    • 16 kHz (wideband telephony, useful band ≈ 50–7000 Hz)
  • Frequencies to suppress (notches):
    • 60 Hz (main hum)
    • Optional harmonics: 120 Hz, 180 Hz, 240 Hz, 300 Hz
  • Attenuation at each notch:
    • ≥ 50 dB at the center frequency of each harmonic
  • Stopband bandwidth (BW):
    • Approximately 10 Hz (example: 55–65 Hz for the 60 Hz notch)
    • Adjustable: narrower if the tone is very pure, wider if there is mains frequency drift
  • Passband ripple:
    • ≤ 0.5–1 dB in the useful voice band outside the notches
  • Maximum acceptable latency:
    • ≤ 10 ms for real-time conversation
    • If lower latency is required, IIR (biquad notch) is preferred over FIR
  • Phase / phase distortion:
    • FIR: linear phase, but requires very high order (hundreds or thousands of taps) → higher latency and computational cost
    • IIR (biquad notch): non-linear phase, but very efficient with practically zero latency
  • Resource usage:
    • IIR biquad: ~2–4 multiplications per sample per notch (very efficient)
    • Long FIR: tens to thousands of multiplications per sample (high CPU/memory cost)

But my questions are the following:

  • What are the steps I should follow to design the filter?
  • Are the requirements correct, taking into account the ideal behavior of the filter?
  • Is the window method acceptable to solve this problem?
Hi,

I am compelled to ask if you have ever designed a digital filter of any kind before this. If not, then I have to ask why you were given this task. I see this a lot so I was just wondering no problem either way. I guess I would like to find out who is handing out problems to students who have no experience in that area, if in fact that is the case here.

Anyway, I am thinking Hamming and 101 coefficients. To start, does that make any sense to you?
 

atferrari

Joined Jan 6, 2004
5,001
With this, I am not going to contribute in replying to the OP's questions but, long ago, I programmed a PIC 18F (a micro, yes) as a FIR filter and the actual and sole reason was the arrogant reply of someone in a forum (buy one!). As most of my projects are just challenges I propose to myself, once solved somehow, I lost interest with details slowly vanishing in mental fog. Not even can recall the micro nro. Oh my...

The hardest part was creating the dirtiest possible LF signal for testing.

To borrow the indexes I downloaded a 30 days free app.

Pity that I posted about all this in the late EPE forum.

QRT
 

schmitt trigger

Joined Jul 12, 2010
2,027
If you’re studying digital signal processing, for sure you have got a digital filter development software.
When I studied it in the early 1990s, the textbook had attached a floppy disk which had the filter development routines. Do you have something similar?
Or do you want to calculate the polynomials by hand?
 

Attachments

MrAl

Joined Jun 17, 2014
13,667
If you’re studying digital signal processing, for sure you have got a digital filter development software.
When I studied it in the early 1990s, the textbook had attached a floppy disk which had the filter development routines. Do you have something similar?
Or do you want to calculate the polynomials by hand?
Hi,

That reminds me, if I remember right (ha ha) there might be a software called something like "scipy" that does the calculations for these filters, but I've never used it.
I have always done them by hand, which today means using math software but only math software that does regular math like add, subtract, etc., along with Calculus calculations. If I had to remember all the integration formulas from many years ago today, I'd be in trouble :)

Digital signal processing is very interesting I use some of that in my personal image handlers for filtering images and stuff like that. I still have to do a descreening algorithm but I got a little lazy with that.
 
Top