【发布时间】:2019-12-08 23:55:44
【问题描述】:
首先,我在 Stack Exchange 中提出了这个问题,我得到的只是与概念相关的答案,而不是面向实现的。所以,我的问题是我正在尝试创建高通滤波器并使用 Python 实现。
from numpy import cos, sin, pi, absolute, arange
from scipy.signal import kaiserord, lfilter, firwin, freqz, firwin2
from pylab import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show
# Nyquist rate.
nyq_rate = 48000 / 2
# Width of the roll-off region.
width = 500 / nyq_rate
# Attenuation in the stop band.
ripple_db = 12.0
num_of_taps, beta = kaiserord(ripple_db, width)
# Cut-off frequency.
cutoff_hz = 5000.0
# Estimate the filter coefficients.
if num_of_taps % 2 == 0:
num_of_taps = num_of_taps + 1
taps = firwin(num_of_taps, cutoff_hz/nyq_rate, window=('kaiser', beta), pass_zero='highpass')
w, h = freqz(taps, worN=1024)
plot((w/pi)*nyq_rate, absolute(h), linewidth=2)
xlabel('Frequency (Hz)')
ylabel('Gain')
title('Frequency Response')
ylim(-0.05, 1.05)
grid(True)
show()
通过查看频率响应,我没有得到预期的阻带衰减。我想要 12dB 的衰减,但我没有得到。我做错了什么?
【问题讨论】:
标签: scipy filtering signal-processing audio-processing