Gammatone Filterbank Toolkit 1.0

gammatone.filters – gammatone filterbank construction

«  Index   ::   Contents   ::   gammatone.gtgram – spectrogram-like gammatone analysis  »

gammatone.filters – gammatone filterbank construction

This module contains functions for constructing sets of equivalent rectangular bandwidth gammatone filters.

gammatone.filters.centre_freqs(fs, num_freqs, cutoff)

Calculates an array of centre frequencies (for make_erb_filters()) from a sampling frequency, lower cutoff frequency and the desired number of filters.

Parameters:
  • fs – sampling rate
  • num_freqs (int) – number of centre frequencies to calculate
  • cutoff – lower cutoff frequency
Returns:

same as erb_space()

gammatone.filters.erb_filterbank(wave, coefs)
Parameters:
  • wave – input data (one dimensional sequence)
  • coefs – gammatone filter coefficients

Process an input waveform with a gammatone filter bank. This function takes a single sound vector, and returns an array of filter outputs, one channel per row.

The fcoefs parameter, which completely specifies the Gammatone filterbank, should be designed with the make_erb_filters() function.

Malcolm Slaney @ Interval, June 11, 1998.
(c) 1998 Interval Research Corporation
Thanks to Alain de Cheveigne’ for his suggestions and improvements.

(c) 2013 Jason Heeris (Python implementation)
gammatone.filters.erb_point(low_freq, high_freq, fraction)

Calculates a single point on an ERB scale between low_freq and high_freq, determined by fraction. When fraction is 1, low_freq will be returned. When fraction is 0, high_freq will be returned.

fraction can actually be outside the range [0, 1], which in general isn’t very meaningful, but might be useful when fraction is rounded a little above or below [0, 1] (eg. for plot axis labels).

gammatone.filters.erb_space(low_freq=100, high_freq=11025.0, num=100)

This function computes an array of num frequencies uniformly spaced between high_freq and low_freq on an ERB scale.

For a definition of ERB, see Moore, B. C. J., and Glasberg, B. R. (1983). “Suggested formulae for calculating auditory-filter bandwidths and excitation patterns,” J. Acoust. Soc. Am. 74, 750-753.

gammatone.filters.make_erb_filters(fs, centre_freqs, width=1.0)

This function computes the filter coefficients for a bank of Gammatone filters. These filters were defined by Patterson and Holdworth for simulating the cochlea.

The result is returned as a ERBCoeffArray. Each row of the filter arrays contains the coefficients for four second order filters. The transfer function for these four filters share the same denominator (poles) but have different numerators (zeros). All of these coefficients are assembled into one vector that the ERBFilterBank can take apart to implement the filter.

The filter bank contains “numChannels” channels that extend from half the sampling rate (fs) to “lowFreq”. Alternatively, if the numChannels input argument is a vector, then the values of this vector are taken to be the center frequency of each desired filter. (The lowFreq argument is ignored in this case.)

Note this implementation fixes a problem in the original code by computing four separate second order filters. This avoids a big problem with round off errors in cases of very small cfs (100Hz) and large sample rates (44kHz). The problem is caused by roundoff error when a number of poles are combined, all very close to the unit circle. Small errors in the eigth order coefficient, are multiplied when the eigth root is taken to give the pole location. These small errors lead to poles outside the unit circle and instability. Thanks to Julius Smith for leading me to the proper explanation.

Execute the following code to evaluate the frequency response of a 10 channel filterbank:

fcoefs = MakeERBFilters(16000,10,100);
y = ERBFilterBank([1 zeros(1,511)], fcoefs);
resp = 20*log10(abs(fft(y')));
freqScale = (0:511)/512*16000;
semilogx(freqScale(1:255),resp(1:255,:));
axis([100 16000 -60 0])
xlabel('Frequency (Hz)'); ylabel('Filter Response (dB)');
Rewritten by Malcolm Slaney@Interval. June 11, 1998.
(c) 1998 Interval Research Corporation

(c) 2012 Jason Heeris (Python implementation)

«  Index   ::   Contents   ::   gammatone.gtgram – spectrogram-like gammatone analysis  »