bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / signal / _filter_design / gammatone
function
scipy.signal._filter_design:gammatone
source: build-install/usr/lib/python3.14/site-packages/scipy/signal/_filter_design.py:5898
Signature
def gammatone(freq, ftype, order = None, numtaps = None, fs = None, *, xp = None, device = None)Summary
Gammatone filter design.
Extended Summary
This function computes the coefficients of an FIR or IIR gammatone digital filter [1].
Parameters
freq: floatCenter frequency of the filter (expressed in the same units as
fs).ftype: {'fir', 'iir'}The type of filter the function generates. If 'fir', the function will generate an Nth order FIR gammatone filter. If 'iir', the function will generate an 8th order digital IIR filter, modeled as as 4th order gammatone filter.
order: int, optionalThe order of the filter. Only used when
ftype='fir'. Default is 4 to model the human auditory system. Must be between 0 and 24.numtaps: int, optionalLength of the filter. Only used when
ftype='fir'. Default isfs*0.015iffsis greater than 1000, 15 iffsis less than or equal to 1000.fs: float, optionalThe sampling frequency of the signal.
freqmust be between 0 andfs/2. Default is 2.xp: array_namespace, optionalOptional array namespace. Should be compatible with the array API standard, or supported by array-api-compat. Default:
numpydevice: anyoptional device specification for output. Should match one of the supported device specification in
xp.
Returns
b, a: ndarray, ndarrayNumerator (
b) and denominator (a) polynomials of the filter.
Raises
: ValueErrorIf
freqis less than or equal to 0 or greater than or equal tofs/2, ifftypeis not 'fir' or 'iir', iforderis less than or equal to 0 or greater than 24 whenftype='fir'
Examples
16-sample 4th order FIR Gammatone filter centered at 440 Hzfrom 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]), array([1.]))
IIR Gammatone filter centered at 440 Hz
import matplotlib.pyplot as plt import numpy as np✓
fc, fs = 440, 16000 b, a = signal.gammatone(fc, 'iir', fs=fs) w, h = signal.freqz(b, a)✓
plt.plot(w * fs / (2 * np.pi), 20 * np.log10(abs(h)))
✗[<matplotlib.lines.Line2D object at 0x7f3f60fee900>]
plt.xscale('log')
✓plt.title('Gammatone filter frequency response') plt.xlabel('Frequency [Hz]') plt.ylabel('Amplitude [dB]')✗
Text(0, 0.5, 'Amplitude [dB]')
plt.margins(0, 0.1) plt.grid(which='both', axis='both')✓
plt.axvline(fc, color='green') # cutoff frequency
✗<matplotlib.lines.Line2D object at 0x7f3f60feecf0>
plt.show()
✓
See also
Aliases
scipy.signal.gammatone