本文簡要介紹 python 語言中 scipy.signal.gammatone
的用法。
用法:
scipy.signal.gammatone(freq, ftype, order=None, numtaps=None, fs=None)#
Gammatone 濾波器設計。
此函數計算 FIR 或 IIR 伽馬調數字濾波器 [1] 的係數。
- freq: 浮點數
濾波器的中心頻率(以與 fs 相同的單位表示)。
- ftype: {‘fir’, ‘iir’}
函數生成的過濾器類型。如果‘fir’,該函數將生成一個 N 階 FIR gammatone 濾波器。如果‘iir’,該函數將生成一個 8 階數字 IIR 濾波器,建模為 4 階 gammatone 濾波器。
- order: 整數,可選
過濾器的順序。僅在
ftype='fir'
時使用。默認值為 4 以模擬人類聽覺係統。必須介於 0 和 24 之間。- numtaps: 整數,可選
過濾器的長度。僅在使用時
ftype='fir'
.默認為fs*0.015
如果fs大於 1000, 15 如果fs小於或等於 1000。- fs: 浮點數,可選
信號的采樣頻率。頻率必須介於 0 和
fs/2
.默認值為 2。
- b, a: 數組,數組
濾波器的分子 (
b
) 和分母 (a
) 多項式。
- ValueError
如果頻率小於或等於 0 或大於或等於
fs/2
, 如果類型不是 ‘fir’ 或 ‘iir’,如果次序小於或等於 0 或大於 24 時ftype='fir'
參數 ::
返回 ::
拋出 ::
參考:
[1]Slaney, Malcolm,“Patterson-Holdsworth 聽覺濾波器組的有效實現”,Apple Computer Technical Report 35, 1993, pp.3-8, 34-39。
例子:
以 440 Hz 為中心的 16 個樣本四階 FIR Gammatone 濾波器
>>> 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])
IIR Gammatone 濾波器以 440 Hz 為中心
>>> import matplotlib.pyplot as plt >>> import numpy as np
>>> 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()
相關用法
- Python SciPy signal.gausspulse用法及代碼示例
- Python SciPy signal.gauss_spline用法及代碼示例
- Python SciPy signal.group_delay用法及代碼示例
- Python SciPy signal.get_window用法及代碼示例
- Python SciPy signal.czt_points用法及代碼示例
- Python SciPy signal.chirp用法及代碼示例
- Python SciPy signal.residue用法及代碼示例
- Python SciPy signal.iirdesign用法及代碼示例
- Python SciPy signal.max_len_seq用法及代碼示例
- Python SciPy signal.kaiser_atten用法及代碼示例
- Python SciPy signal.oaconvolve用法及代碼示例
- Python SciPy signal.hilbert用法及代碼示例
- Python SciPy signal.ricker用法及代碼示例
- Python SciPy signal.cheb2ord用法及代碼示例
- Python SciPy signal.lfilter用法及代碼示例
- Python SciPy signal.morlet用法及代碼示例
- Python SciPy signal.coherence用法及代碼示例
- Python SciPy signal.dfreqresp用法及代碼示例
- Python SciPy signal.TransferFunction用法及代碼示例
- Python SciPy signal.dbode用法及代碼示例
- Python SciPy signal.residuez用法及代碼示例
- Python SciPy signal.bilinear_zpk用法及代碼示例
- Python SciPy signal.firls用法及代碼示例
- Python SciPy signal.impulse用法及代碼示例
- Python SciPy signal.buttord用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.signal.gammatone。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。