0
0
RosConceptBeginner · 4 min read

What is a Biquad Filter: Definition and Usage Explained

A biquad filter is a type of digital filter that uses two poles and two zeros to shape signals. It is commonly used for audio and signal processing because it can implement many filter types like low-pass, high-pass, and band-pass with simple equations.
⚙️

How It Works

A biquad filter works like a smart signal shaper that changes the sound or data by emphasizing or reducing certain frequencies. Imagine it as a water faucet with two knobs: one controls how much water flows out (gain), and the other controls how the water pressure changes (frequency response). These two knobs correspond to the filter's poles and zeros, which define how the filter reacts to different frequencies.

In simple terms, the biquad filter uses a small set of numbers (coefficients) to calculate each output point based on current and past inputs and outputs. This makes it efficient and flexible, allowing it to create many common filter effects by just changing these numbers.

💻

Example

This example shows how to create a simple low-pass biquad filter using Python and the scipy library. It filters a noisy signal to keep only the low frequencies.
python
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import lfilter

# Sample rate and desired cutoff frequency (Hz)
sample_rate = 48000
cutoff_freq = 1000

# Calculate normalized frequency
omega = 2 * np.pi * cutoff_freq / sample_rate

# Biquad low-pass filter coefficients (Butterworth)
b = [omega**2, 2*omega**2, omega**2]
a = [1 + np.sqrt(2)*omega + omega**2, -2 + 2*omega**2, 1 - np.sqrt(2)*omega + omega**2]

# Normalize coefficients
a = np.array(a) / a[0]
b = np.array(b) / a[0]

# Create a noisy signal
T = 0.01
t = np.linspace(0, T, int(sample_rate*T), endpoint=False)
signal = np.sin(2*np.pi*300*t) + 0.5*np.sin(2*np.pi*3000*t)

# Apply the biquad filter
filtered_signal = lfilter(b, a, signal)

# Plot original and filtered signals
plt.plot(t, signal, label='Original Signal')
plt.plot(t, filtered_signal, label='Filtered Signal')
plt.legend()
plt.xlabel('Time [s]')
plt.ylabel('Amplitude')
plt.title('Biquad Low-Pass Filter Example')
plt.show()
Output
A plot showing the original noisy signal with high-frequency noise and the filtered signal with mostly low-frequency content preserved.
🎯

When to Use

Use a biquad filter when you need a simple, efficient way to shape or clean signals in real time. They are perfect for audio equalizers, noise reduction, and sensor data smoothing because they require few calculations and can be tuned easily.

For example, in music apps, biquad filters help adjust bass or treble. In electronics, they clean sensor signals to remove unwanted noise. Their flexibility makes them a go-to choice for many digital signal processing tasks.

Key Points

  • A biquad filter uses two poles and two zeros to control frequency response.
  • It can implement many filter types like low-pass, high-pass, band-pass, and notch.
  • It is efficient and suitable for real-time digital signal processing.
  • Filter behavior is controlled by a small set of coefficients.

Key Takeaways

A biquad filter is a versatile digital filter using two poles and two zeros.
It efficiently shapes signals by adjusting frequency components in real time.
Commonly used in audio processing, noise reduction, and sensor data filtering.
Filter behavior is controlled by simple coefficients that define its frequency response.