FIR Filter Design Calculator

Design low-pass, high-pass, band-pass, and band-stop FIR filters using windowed-sinc or equiripple (Parks–McClellan-like) methods. Visualize the magnitude response and export coefficients.

1. Filter specifications

Used to convert between Hz and normalized frequency.

Higher N → sharper transition, more delay and computation.

For low-pass/high-pass: main cutoff. For band filters: lower edge.

Used for windowed-sinc method.

2. Magnitude response

Magnitude (dB) vs frequency

3. FIR coefficients (taps)

Press “Design FIR filter” to generate taps.

How this FIR filter design tool works

This calculator designs linear-phase FIR filters using two classic approaches:

  • Windowed-sinc method – simple, robust, and great for quick prototypes.
  • Equiripple (Parks–McClellan-like) – approximated here by iteratively shaping the window to better match your ripple/attenuation targets.

1. FIR filter basics

An FIR filter of length \(N\) has impulse response \(h[n]\) and output

\( y[n] = \sum_{k=0}^{N-1} h[k]\,x[n-k] \)

For linear-phase FIR filters we choose symmetric coefficients:

\( h[k] = h[N-1-k] \)

This symmetry makes the phase response linear and the group delay constant:

\( \tau_g = \dfrac{N-1}{2} \text{ samples} \)

2. Windowed-sinc design

The ideal low-pass filter has frequency response \( H_\text{ideal}(\omega) = 1 \) for \(|\omega| \le \omega_c\) and 0 otherwise. Its impulse response is the sinc function:

\( h_\text{ideal}[n] = \dfrac{\sin\big(\omega_c (n - M)\big)}{\pi (n - M)}, \quad M = \dfrac{N-1}{2} \)

Because this response is infinitely long, we truncate it with a window \(w[n]\):

\( h[n] = h_\text{ideal}[n] \cdot w[n], \quad 0 \le n \le N-1 \)

Different windows trade off main-lobe width (transition sharpness) and side-lobe level (stopband attenuation):

  • Rectangular – narrowest transition, poor sidelobes (~−13 dB).
  • Hann – better sidelobes (~−44 dB), wider transition.
  • Hamming – ~−53 dB sidelobes, commonly used.
  • Blackman – ~−74 dB sidelobes, widest transition.

3. Equiripple (Parks–McClellan) idea

The Parks–McClellan algorithm directly optimizes the filter to minimize the maximum error between the desired and actual response (Chebyshev approximation). The resulting magnitude response has nearly equal ripples in passband and stopband.

In this browser-based tool we approximate this behavior by:

  1. Starting from a windowed-sinc design.
  2. Measuring passband and stopband errors.
  3. Iteratively adjusting an internal shaping window to reduce the maximum error.

For production work, you should still validate the design in a DSP environment such as MATLAB, Octave, SciPy, or a hardware toolchain.

4. Choosing the number of taps

A widely used rule of thumb for windowed-sinc low-pass filters is:

\( N \approx \dfrac{A - 8}{2.285 \cdot 2\pi \Delta f} \)

where:

  • \(A\) is desired stopband attenuation in dB.
  • \(\Delta f\) is the normalized transition width (from passband edge to stopband edge, divided by \(f_s\)).

Use this as a starting point, then increase or decrease \(N\) while watching the magnitude plot.

5. Exporting and using the coefficients

Once you are satisfied with the response:

  • Click Copy as comma-separated to paste taps into C, Python, MATLAB, etc.
  • Or Download as .txt to save them as a file.

Example C-style snippet:

#define N_TAPS 63
float h[N_TAPS] = {
  /* paste coefficients here */
};
          

FIR filter design FAQ

What is an FIR filter?

A finite impulse response (FIR) filter is a digital filter whose output is a weighted sum of a finite number of past input samples. Because it has no feedback (no dependence on past outputs), it is always stable when the coefficients are finite, and it can be designed to have exactly linear phase.

When should I use FIR instead of IIR?

Use FIR filters when you need:

  • Strictly linear phase (e.g., audio, communications, instrumentation).
  • Guaranteed stability and simple fixed-point behavior.
  • Flexible multiband or arbitrary-magnitude designs.

IIR filters are more efficient for very sharp transitions but have nonlinear phase and can be unstable if not carefully implemented.

Why does my filter have so much delay?

Linear-phase FIR filters have a group delay of \((N-1)/2\) samples. If you increase the number of taps to get a sharper transition, you also increase the delay. For real-time applications, you must balance frequency-domain performance against latency.

How accurate is this browser-based design?

The core math (sinc generation, windowing, FFT-based response) is standard. The “equiripple” mode is an approximation of Parks–McClellan, not a full implementation. For critical designs, you should:

  • Export the taps.
  • Verify them in MATLAB/Octave/SciPy or your DSP toolchain.
  • Test with representative signals and quantization.