Signal Processing Visualizer
Explore waveforms and filters interactively in real-time
- Select a waveform type from the dropdown menu (Sine, Square, Triangle, Sawtooth, or Pulse).
- Adjust the amplitude, frequency, and phase sliders to modify the input signal.
- Choose a filter type to see how it affects the waveform in real-time.
- For low-pass and high-pass filters, adjust the cutoff frequency and resonance.
- For band-pass and band-stop filters, set the center frequency and bandwidth.
- Use the preset buttons for quick configurations.
- Press Space to pause or resume the animation.
- Click the Screenshot button to save the current visualization.
📚 Signal Processing Background
📡 What is Signal Processing?
Signal processing is the analysis, manipulation, and interpretation of signals—functions that convey information about phenomena. Signals can be sound waves, images, sensor data, communication transmissions, or any time-varying or spatially-varying quantity. Filtering is one of the most fundamental signal processing operations.
A filter is a system that modifies a signal by selectively allowing certain frequencies to pass through while attenuating others. This is crucial in removing noise, extracting features, separating signals, and countless other applications in engineering, science, and technology.
🌊 Understanding Waveforms
Before exploring filters, let's understand the basic waveforms visualized in this tool:
Sine Wave
y(t) = A sin(2πft + φ)
The fundamental periodic waveform. Pure sine waves contain only a single frequency component. In nature, tuning forks produce nearly pure sine waves. In mathematics and physics, sine waves are the building blocks for all other periodic signals (Fourier's theorem).
Square Wave
Alternates between two constant values (high and low). Contains the fundamental frequency plus odd harmonics (3f, 5f, 7f, ...) with decreasing amplitude. Common in digital electronics and clock signals. Mathematically, it's the sum of infinite odd harmonics:
y(t) = (4/π) Σ [sin(2π(2n-1)ft) / (2n-1)] for n = 1, 2, 3...
Triangle Wave
Linear rise and fall between two values. Like square waves, contains only odd harmonics but they decrease faster (1/n² vs 1/n), making it sound mellower. Common in music synthesis and function generators.
Sawtooth Wave
Linear rise followed by sharp drop (or vice versa). Contains all harmonics (both odd and even) with amplitude decreasing as 1/n. Rich in harmonics, producing a "buzzy" sound. Common in music synthesis and sweep generators.
Pulse Wave
Similar to square wave but with adjustable duty cycle (percentage of time spent high). A 50% duty cycle is a square wave. Used extensively in PWM (Pulse Width Modulation) for motor control and power conversion.
📐 Frequency Domain and Fourier Analysis
Understanding filters requires understanding the frequency domain. Any periodic signal can be represented as a sum of sine and cosine waves at different frequencies (Fourier series). Non-periodic signals can be represented as integrals over frequency (Fourier transform).
Fourier Transform:
X(f) = ∫ x(t) e^(-j2πft) dt
Converts time-domain signal x(t) to frequency-domain X(f)
Key Insight: While we experience signals in the time domain (amplitude vs time), filters primarily operate in the frequency domain (amplitude vs frequency). A filter's frequency response describes how it affects each frequency component.
Filtering in Frequency Domain:
Y(f) = H(f) × X(f)
where H(f) is the filter's transfer function
This multiplication in frequency domain corresponds to convolution in time domain. Convolution is computationally expensive, so frequency-domain processing (using FFT) is often more efficient for digital signal processing.
🔽 Low-Pass Filter
Purpose: A low-pass filter allows low frequencies to pass through while attenuating (reducing) high frequencies above a cutoff frequency.
Ideal Low-Pass Filter Frequency Response:
H(f) = 1 for |f| ≤ f_c (passband)
H(f) = 0 for |f| > f_c (stopband)
where f_c is the cutoff frequency
Real Filter (First-Order):
H(f) = 1 / (1 + j(f/f_c))
|H(f)| = 1 / √(1 + (f/f_c)²)
At f = f_c: |H(f_c)| = 1/√2 ≈ 0.707 (-3 dB point)
Roll-off rate: -20 dB/decade (-6 dB/octave)
Physical Interpretation: Low-pass filters act as smoothing operators. They remove rapid variations (high frequencies) while preserving slow variations (low frequencies). Think of them as averaging out the jagged edges.
Applications:
- Audio Processing: Removing high-frequency noise, creating bass boost, speaker crossover networks
- Image Processing: Blurring images, removing noise (Gaussian blur is a low-pass filter)
- Anti-Aliasing: Preventing aliasing in analog-to-digital conversion by removing frequencies above Nyquist limit
- Sensor Smoothing: Removing high-frequency noise from sensor readings
- Communications: Channel bandwidth limiting, demodulation
Example: In audio, a subwoofer uses a low-pass filter to only reproduce bass frequencies (below ~200 Hz), filtering out mids and highs sent to other speakers.
🔼 High-Pass Filter
Purpose: A high-pass filter allows high frequencies to pass through while attenuating low frequencies below a cutoff frequency. It's the complement of a low-pass filter.
Ideal High-Pass Filter Frequency Response:
H(f) = 0 for |f| < f_c (stopband)
H(f) = 1 for |f| ≥ f_c (passband)
Real Filter (First-Order):
H(f) = j(f/f_c) / (1 + j(f/f_c))
|H(f)| = (f/f_c) / √(1 + (f/f_c)²)
At f = f_c: |H(f_c)| = 1/√2 ≈ 0.707 (-3 dB point)
Roll-off rate: +20 dB/decade (+6 dB/octave) below f_c
Physical Interpretation: High-pass filters emphasize rapid changes and suppress slow variations. They act as edge detectors or differentiators, highlighting transitions while removing DC offset and low-frequency drift.
Applications:
- Audio Processing: Removing rumble and low-frequency noise, AC coupling (blocking DC), creating treble boost
- Image Processing: Edge detection, sharpening images, removing background illumination variations
- AC Coupling: Blocking DC components in amplifier circuits while passing AC signals
- Sensor Processing: Removing DC drift and slow variations in measurements
- Seismology: Filtering out long-period earth movements to detect earthquakes
Example: In audio recording, high-pass filters (often called "rumble filters") remove low-frequency noise from air conditioning, traffic, or mic handling below ~80-100 Hz.
🎚️ Band-Pass Filter
Purpose: A band-pass filter allows frequencies within a specific range (band) to pass while attenuating frequencies outside this range. It combines low-pass and high-pass characteristics.
Key Parameters:
• f_c (center frequency): Middle of the passband
• BW (bandwidth): Width of the passband
• f_L = f_c - BW/2 (lower cutoff frequency)
• f_H = f_c + BW/2 (upper cutoff frequency)
• Q = f_c / BW (quality factor, narrower band → higher Q)
Frequency Response (Second-Order):
H(f) = (j(f/f_c)/Q) / (1 + j(f/f_c)/Q - (f/f_c)²)
Maximum response at f = f_c
-3 dB points at f_L and f_H
Physical Interpretation: Band-pass filters select a specific frequency range, like tuning a radio to a specific station. They reject both low and high frequencies, isolating a "band" of interest.
Applications:
- Radio/Communications: Tuning to specific frequencies, channel selection, rejecting adjacent channels
- Audio Processing: Equalizers (each band is a band-pass filter), isolating specific frequency ranges in music
- Biomedical: Isolating specific brain wave frequencies (EEG: alpha, beta, theta waves), ECG signal processing
- Speech Processing: Isolating formants (resonant frequencies of vocal tract)
- Spectrum Analysis: Measuring power in specific frequency bands
- Optical: Color filters are optical band-pass filters
Example: An FM radio receiver uses a band-pass filter centered at 88-108 MHz to select the desired station while rejecting all other frequencies.
🚫 Band-Stop Filter (Notch Filter)
Purpose: A band-stop filter (also called notch or band-reject filter) attenuates frequencies within a specific range while allowing frequencies outside this range to pass. It's the complement of a band-pass filter.
Key Parameters:
• f_c (center/notch frequency): Middle of the stopband
• BW (bandwidth): Width of the stopband
• Q = f_c / BW (quality factor, narrower notch → higher Q)
Frequency Response:
H(f) = (1 - (f/f_c)²) / (1 + j(f/f_c)/Q - (f/f_c)²)
Minimum (ideally zero) response at f = f_c
Unit response far from f_c
Physical Interpretation: Band-stop filters "notch out" or remove a specific frequency or narrow band of frequencies while leaving everything else intact. Think of them as surgical removers of unwanted frequency components.
Applications:
- Power Line Noise Removal: Removing 50/60 Hz interference (and harmonics) from audio and instrumentation
- Audio Processing: Removing specific frequency resonances or feedback frequencies in PA systems
- Communications: Rejecting specific interfering signals while preserving desired signals
- Biomedical: Removing power line artifacts from EEG, ECG recordings
- Radar: Suppressing clutter at specific Doppler frequencies
- Image Processing: Removing periodic noise patterns
Example: Studio microphones often include a notch filter at 50 or 60 Hz to eliminate power line hum without affecting voice quality.
🎛️ Filter Parameters and Characteristics
Cutoff Frequency (f_c)
The frequency at which the filter's output power is half (-3 dB) of the passband power. This is also called the half-power point or -3 dB point. It marks the transition between passband and stopband.
-3 dB = 20 log₁₀(1/√2) ≈ -3.01 dB
Power ratio: 0.5 (-3 dB)
Amplitude ratio: 1/√2 ≈ 0.707
Quality Factor (Q) / Resonance
Measures the "sharpness" of the filter's frequency response. Higher Q means narrower bandwidth and more selective filtering. Also indicates how much the filter resonates at the center frequency.
Q = f_c / BW = f_c / (f_H - f_L)
High Q (>10): Very selective, narrow bandwidth
Low Q (<1): Broad, gentle filtering
In resonant filters, high Q can cause a peak at the cutoff frequency (used in music synthesis for creating characteristic sounds).
Roll-Off Rate (Slope)
The rate at which the filter attenuates signals in the transition band, typically measured in dB/octave or dB/decade.
First-order filter: 20 dB/decade = 6 dB/octave
Second-order filter: 40 dB/decade = 12 dB/octave
nth-order filter: n × 20 dB/decade
Steeper roll-off (higher order) means sharper transition but more complex implementation and potential phase distortion.
Phase Response
Filters not only change amplitude but also introduce phase shifts—different frequencies are delayed by different amounts. This can cause signal distortion, especially in audio and control systems.
First-order low-pass: φ(f) = -arctan(f/f_c)
At f_c: phase shift = -45°
As f → ∞: phase shift → -90°
Linear phase filters (like FIR filters) delay all frequencies equally, preserving waveform shape—critical for audio fidelity and data transmission.
📊 Filter Comparison and Design Trade-offs
| Filter Type | Passes | Blocks | Use Case |
|---|---|---|---|
| Low-Pass | f < f_c | f > f_c | Smoothing, noise removal |
| High-Pass | f > f_c | f < f_c | Edge detection, AC coupling |
| Band-Pass | f_L < f < f_H | f < f_L, f > f_H | Channel selection, tuning |
| Band-Stop | f < f_L, f > f_H | f_L < f < f_H | Interference removal |
Design Trade-offs:
- Sharpness vs Complexity: Steeper roll-off requires higher-order filters (more components, more computation)
- Phase vs Amplitude: Good amplitude response may compromise phase linearity and vice versa
- Time vs Frequency: Sharp frequency selectivity increases time-domain ringing (oscillations)
- Analog vs Digital: Analog filters are real-time but drift with temperature; digital filters are precise but require sampling
🌟 Real-World Applications
Filters are ubiquitous in modern technology:
- Audio Engineering: Equalizers, crossovers, effects (reverb, chorus), noise reduction, mastering. Every sound you hear through speakers has been filtered.
- Telecommunications: Channel separation in cellular networks, noise suppression in voice calls, signal recovery in fiber optics.
- Medical Devices: ECG monitors filter out muscle noise and power line interference. MRI machines use sophisticated filtering for image reconstruction.
- Photography: UV filters, polarizing filters, neutral density filters. Digital post-processing is essentially filtering in multiple dimensions.
- Radar & Sonar: Doppler filtering separates moving targets from clutter. Matched filters optimize detection of known signals in noise.
- Control Systems: Low-pass filters smooth sensor readings in robotics and autonomous vehicles. Prevents high-frequency noise from causing instability.
- Digital Signal Processing: MP3/AAC compression uses filter banks to divide audio into frequency bands. Video compression similarly uses spatial filtering.
- Finance: Moving averages are low-pass filters that smooth out price data to identify trends.
🔬 Advanced Topics
Filter Families and Approximations:
- Butterworth: Maximally flat passband, no ripples. Moderate roll-off. Good general-purpose filter.
- Chebyshev: Sharper roll-off than Butterworth but has ripples in passband (Type I) or stopband (Type II). Better selectivity.
- Elliptic (Cauer): Sharpest roll-off for given order but has ripples in both passband and stopband. Most selective.
- Bessel: Linear phase response (constant group delay), preserves waveform shape. Used when phase distortion must be minimized.
Digital Filter Implementation:
- FIR (Finite Impulse Response): Always stable, can have linear phase, but require more computation. Use convolution with filter coefficients.
- IIR (Infinite Impulse Response): More efficient, mimic analog filters, but can be unstable and have non-linear phase. Use recursive equations.
- FFT-based: Very efficient for long filters. Transform to frequency domain, multiply by filter response, transform back.