Last chance! 50% off unlimited learning
Sale ends in
Generate gammatone filter in the time domain (impulse response).
gammatone(f, d, cfreq, n = 4, a = 1, p = 0, output = "matrix")
A wave is returned. The class of the returned object is set with the argument output
.
sampling frequency (in Hz).
duration (in s).
center frequency (in Hz).
filter order (no unit).
amplitude (linear scale, no unit).
initial phase (in radians).
character string, the class of the object to return, either
"matrix"
, "Wave"
, "Sample"
, "audioSample"
or "ts"
.
Jerome Sueur
The gammatone function in the time domain (impulse response) is
obtained with:
The parameter
Holdsworth J, Nimmo-Smith I, Patterson R, Rice P (1988) Implementing a gammatone filter bank. Annex C of the SVOS Final Report: Part A: The Auditory Filterbank, 1, 1-5.
melfilterbank
## gammatone filter in the time domain (impulse response)
f <- 44100
d <- 0.05
res <- gammatone(f=f, d=d, cfreq=440, n=4)
## time display
oscillo(res, f=f)
## frequency display
spec(res, f=f)
## generate and plot a bank of 32 filters from 500 to 10000 Hz
n <- 32
cfreq <- round(seq(500, 10000, length.out=n))
res <- matrix(NA, nrow=f*d/2, ncol=n)
for(i in 1:n){
res[,i] <- spec(gammatone(f=f, d=d, cfreq=cfreq[i]), f=f, dB="max0", plot=FALSE)[,2]
}
x <- seq(0,f/2,length.out=nrow(res))/1000
plot(x=x, y=res[,1],
xlim=c(0,14), ylim=c(-60,0),
type="l", col=2, las=1,
xlab="Frequency (kHz)", ylab="Relative amplitude (dB)")
for(i in 2:n) lines(x, res[,i], col=2)
## use the frequency domain to filter a white noise input
## here around the center frequency 2000 Hz
res <- gammatone(f=f, d=d, cfreq=2000, n=4)
gspec <- spec(res, f=f, plot=FALSE)[,2]
nw <- noisew(f=44100, d=1)
nwfilt <- fir(nw, f=44100, wl=length(gspec)*2, custom=gspec)
spectro(nwfilt, f=f)
Run the code above in your browser using DataLab