Digital Filter Design Back
Signal Processing

Digital Filter Design — Frequency Response Simulator

Choose Butterworth IIR or windowed FIR, select filter type (LP/HP/BP/BS), then tune cutoff frequency and order with sliders. Magnitude (dB) and phase response update live on a log-frequency axis.

Filter Settings
Filter Type
Design Method
Sampling Rate fs 1000 Hz
Cutoff fc₁ 200 Hz
Filter Order N 4
Summary Stats
-3 dB freq.
Stopband att.
Group delay (ms)

Theory Note

fc₁ (Hz)
Nyquist (Hz)
Order N
Magnitude Response [dB] — log frequency
Phase Response [degrees]
Block Diagram

What is Digital Filter Design?

🧑‍🎓
What exactly is a "digital filter," and why would I use one instead of an analog circuit?
🎓
Basically, a digital filter is a mathematical algorithm that processes a stream of numbers (your digitized signal) to remove unwanted frequencies. In practice, it's software, not hardware. The big advantage is perfect reproducibility and no component drift. Try switching the "Design Method" above between Butterworth and FIR to see two fundamentally different approaches.
🧑‍🎓
Wait, really? So Butterworth and FIR are totally different? The simulator shows graphs for both. What's the main trade-off?
🎓
Great question. Yes, they're different families. Butterworth is an IIR filter; it uses feedback for a very sharp frequency cut-off with a low "Filter Order" (N). FIR filters use no feedback, so they are always stable and can have perfectly linear phase, which prevents signal distortion. The trade-off? For the same sharpness, an FIR needs a much higher order. Slide the "Filter Order N" control up and down while toggling the method to see this dramatically.
🧑‍🎓
Okay, I see the graphs change. But what do the "Cutoff" frequencies and "Window Function" actually do? They seem like magic knobs.
🎓
They're your design knobs! The Cutoff frequency (fc) is your target—where you want the filter to start attenuating the signal. For a bandpass filter, you use fc₁ and fc₂ to define the passband. The "Window Function" (like Hamming or Blackman) is specific to FIR design; it tapers the filter's impulse response to reduce ripples in the passband. A common case is using a Hamming window for a good balance. Change the window and watch the ripples in the magnitude response smooth out.

Physical Model & Key Equations

The core of a digital filter is its transfer function, H(z), which describes its frequency response. For an IIR filter like Butterworth, it's derived from an analog prototype and uses a rational function (feedback).

$$H(z) = \frac{\sum_{k=0}^{M}b_k z^{-k}}{1 + \sum_{k=1}^{N}a_k z^{-k}}$$

Here, $z = e^{j\omega}$ is the complex frequency variable, $\omega = 2\pi f/f_s$ is the digital frequency, $f_s$ is the sampling rate, and $a_k$, $b_k$ are the filter coefficients. The order $N$ determines the number of feedback terms and the steepness of the roll-off.

For an FIR filter, the transfer function has no denominator (no feedback, so all $a_k=0$). It's defined by its impulse response coefficients, often designed using a window function $w[n]$.

$$h[n] = h_d[n] \cdot w[n], \quad n=0,1,...,N-1$$ $$H(z) = \sum_{n=0}^{N-1}h[n] z^{-n}$$

$h_d[n]$ is the ideal impulse response (e.g., a sinc function for a low-pass filter), and $w[n]$ is the window (Hamming, Hanning, etc.) that truncates and shapes it. The phase response is linear if $h[n]$ is symmetric, which is a key advantage for FIR filters.

Real-World Applications

Audio Processing & Equalization: Every digital audio workstation and music streaming app uses filters. For instance, the bass and treble controls on your phone are essentially low-pass and high-pass filters. Engineers use tools like this simulator to design crossover networks for speakers, ensuring drivers only receive the frequencies they are built to handle.

Noise Reduction in Communications: In a mobile phone, your voice signal is contaminated with background noise (like wind or chatter). A bandpass filter, designed with specific cutoff frequencies (fc₁ and fc₂) to match the human voice range (~300 Hz to 3400 Hz), is applied to strip out the low-frequency rumble and high-frequency hiss before the signal is transmitted.

Biomedical Signal Analysis: When measuring an ECG (heart signal), the raw data includes muscle noise and powerline interference (50/60 Hz). A digital notch filter (a very narrow band-stop filter) is designed to surgically remove the 60 Hz hum without distorting the crucial heart waveform. The filter order and type are critical here.

Image Processing (2D Filtering): While this simulator shows 1D frequency response, the same principles extend to two dimensions. Sharpening or blurring a digital image is done by applying a 2D low-pass (blur) or high-pass (sharpen) filter to the pixel data. Designing the 1D filter is the first step in constructing these 2D kernels.

Common Misconceptions and Points to Note

First, there is a misconception that "a higher filter order N is always better." While increasing the order does make the roll-off steeper, it also increases computational load and can introduce problematic latency in real-time processing. For instance, when processing on a microcontroller, exceeding N=8 for a Butterworth IIR filter risks instability due to the effects of coefficient quantization error. In practice, you should identify the "necessary and sufficient performance"; for low-pass filters, they are often designed with N=4 to 6.

Next is the mistake of mis-setting the cutoff frequency $f_c$. While you can freely adjust $f_c$ in a simulator, you must not forget the sampling theorem in actual signal processing. If the sampling frequency $f_s$ is 10 kHz, the theoretically highest frequency you can handle is 5 kHz (the Nyquist frequency). Setting $f_c$ to 4.8 kHz here puts you in the danger zone for aliasing (foldover distortion). The standard practice is to maintain a safety margin by keeping $f_c$ at or below 1/4 of $f_s$ (below 2.5 kHz in this example).

Finally, there is the "initial transient" problem caused by applying a filter. Because filters depend on past data, the output is unstable immediately after application. For example, the first 0.1 seconds of vibration data is unreliable as the filter has not yet reached a steady state. In practice, you need to either exclude this transient response period or use techniques like bidirectional filtering (filtfilt processing) to eliminate phase distortion.

Related Engineering Fields

The concept of "frequency response" you learn with this simulator is deeply connected to control engineering. The amplitude/phase characteristics of a filter are essentially the Bode plot used to evaluate control system stability. For example, in servo motor position control, you design a low-pass filter (a low-pass filter in controller terms) to suppress high-frequency noise and ensure sufficient phase margin for the entire system.

Furthermore, in acoustics and audio processing, the linear phase characteristic of FIR filters is indispensable. Multiple band-pass filters are used inside music EQs (equalizers) and audio codecs (AAC, Opus). Particularly in compression utilizing the masking effect based on the "psychoacoustic model," frequency components inaudible to humans are actively removed by filters.

As a more advanced application, there is modulation/demodulation technology in communications engineering. In wireless communications, band-pass filters that pass only a specific channel (frequency band) while blocking others are key. In 5G or Wi-Fi base stations, window functions (like the Kaiser window) with excellent side-lobe suppression, as you might have experimented with in the simulator, are used in FIR design to prevent adjacent channel interference.

For Further Learning

The first next step is to "apply it to real signals and observe the effects." Try applying the filter coefficients ($a_k$, $b_k$) you designed in the simulator to actual time-series data (e.g., an audio file) using Python (SciPy's signal library) or MATLAB. Comparing the waveform and spectrum before and after filtering will let you experientially understand "how phase distortion affects perception."

If you want to deepen the mathematical background, understanding the "z-transform" is essential. Representing the difference equation in the z-domain allows the filter's characteristics to be interpreted geometrically by the placement of its "poles" and "zeros." For example, learning that the poles of a Butterworth filter are equally spaced on the unit circle and that this arrangement is determined by the order N will give you a deeper understanding of the simulator's behavior. The transfer function is expressed as: $$H(z) = \frac{\sum_{k=0}^{M}b_k z^{-k}}{1 + \sum_{k=1}^{N}a_k z^{-k}}$$

Finally, using this tool as a starting point, we recommend progressing to advanced topics like adaptive filters and wavelet transforms. Adaptive filters (e.g., the LMS algorithm) are techniques that automatically adjust coefficients when noise frequency changes over time (e.g., cabin noise in a moving vehicle). Wavelets, which can analyze both frequency and time locality simultaneously, become powerful tools for non-stationary signal analysis, such as detecting impact waveforms.