scipy.signal.gammatone¶
- scipy.signal.gammatone(freq, ftype, order=None, numtaps=None, fs=None)[源代码]¶
伽马通过滤设计。
此函数用于计算FIR或IIR伽马通数字过滤的系数 [1].
- 参数
- freq浮动
过滤中心频率(单位相同 fs )。
- ftype{‘FIR’,‘IIR’}
函数生成的过滤的类型。如果为‘FIR’,则该函数将生成一个第N阶的FIR伽马通过滤。如果为‘iir’,则该函数将生成一个8阶数字iIR过滤,模拟为4阶伽马酮过滤。
- order整型,可选
过滤勋章。仅在以下情况下使用
ftype='fir'
。默认值为4,用于对人类听觉系统进行建模。必须介于0和24之间。- numtaps整型,可选
过滤的长度。仅在以下情况下使用
ftype='fir'
。默认值为fs*0.015
如果 fs 大于1000,如果 fs 小于或等于1000。- fs浮动,可选
信号的采样频率。 freq 必须介于0和0之间
fs/2
。默认值为2。
- 退货
- b, andarray,ndarray
分子 (
b
)和分母 (a
)过滤的多项式。
- 加薪
- ValueError
如果 freq 小于或等于0或大于或等于
fs/2
,如果 ftype 不是“FIR”或“IIR”,如果 order 在以下情况下小于或等于0或大于24ftype='fir'
参考文献
- 1
马尔科姆·斯兰尼,“帕特森-霍尔兹沃斯听觉过滤银行的有效实施”,“苹果计算机技术报告”,第35期,1993年,第3-8页,第34-39页。
示例
以440 Hz为中心的16个样本的4阶FIR伽马通过滤
>>> from scipy import signal >>> signal.gammatone(440, 'fir', numtaps=16, fs=16000) (array([ 0.00000000e+00, 2.22196719e-07, 1.64942101e-06, 4.99298227e-06, 1.01993969e-05, 1.63125770e-05, 2.14648940e-05, 2.29947263e-05, 1.76776931e-05, 2.04980537e-06, -2.72062858e-05, -7.28455299e-05, -1.36651076e-04, -2.19066855e-04, -3.18905076e-04, -4.33156712e-04]), [1.0])
以440 Hz为中心的IIR伽马通过滤
>>> from scipy import signal >>> import matplotlib.pyplot as plt
>>> b, a = signal.gammatone(440, 'iir', fs=16000) >>> w, h = signal.freqz(b, a) >>> plt.plot(w / ((2 * np.pi) / 16000), 20 * np.log10(abs(h))) >>> plt.xscale('log') >>> plt.title('Gammatone filter frequency response') >>> plt.xlabel('Frequency') >>> plt.ylabel('Amplitude [dB]') >>> plt.margins(0, 0.1) >>> plt.grid(which='both', axis='both') >>> plt.axvline(440, color='green') # cutoff frequency >>> plt.show()