gammatone.fftweight – FFT weightings for spectrogram-like gammatone analysis¶
This module contains functions for calculating weights to approximate a gammatone filterbank-like “spectrogram” from a Fourier transform.
- gammatone.fftweight.fft_gtgram(wave, fs, window_time, hop_time, channels, f_min)¶
Calculate a spectrogram-like time frequency magnitude array based on an FFT-based approximation to gammatone subband filters.
A matrix of weightings is calculated (using gtgram.fft_weights()), and applied to the FFT of the input signal (wave, using sample rate fs). The result is an approximation of full filtering using an ERB gammatone filterbank (as per gtgram.gtgram()).
f_min determines the frequency cutoff for the corresponding gammatone filterbank. window_time and hop_time (both in seconds) are the size and overlap of the spectrogram columns.
- gammatone.fftweight.fft_weights(nfft, fs, nfilts, width, fmin, fmax, maxlen)¶
Parameters: - nfft – the source FFT size
- sr – sampling rate (Hz)
- nfilts – the number of output bands required (default 64)
- width – the constant width of each band in Bark (default 1)
- fmin – lower limit of frequencies (Hz)
- fmax – upper limit of frequencies (Hz)
- maxlen – number of bins to truncate the rows to
Returns: a tuple weights, gain with the calculated weight matrices and gain vectors
Generate a matrix of weights to combine FFT bins into Gammatone bins.
Note about maxlen parameter: While wts has nfft columns, the second half are all zero. Hence, aud spectrum is:
fft2gammatonemx(nfft,sr)*abs(fft(xincols,nfft))
maxlen truncates the rows to this many bins.
(c) 2004-2009 Dan Ellis dpwe@ee.columbia.edu based on rastamat/audspec.m(c) 2012 Jason Heeris (Python implementation)
- gammatone.fftweight.specgram(x, n, sr, w, h)¶
Substitute for Matlab’s specgram, calculates a simple spectrogram.
Parameters: - x – The signal to analyse
- n – The FFT length
- sr – The sampling rate
- w – The window length (see specgram_window())
- h – The hop size (must be greater than zero)
- gammatone.fftweight.specgram_window(nfft, nwin)¶
Window calculation used in specgram replacement function. Hann window of width nwin centred in an array of width nfft.