| gammatone {seewave} | R Documentation |
Gammatone filter
Description
Generate gammatone filter in the time domain (impulse response).
Usage
gammatone(f, d, cfreq, n = 4, a = 1, p = 0, output = "matrix")
Arguments
f |
sampling frequency (in Hz). |
d |
duration (in s). |
cfreq |
center frequency (in Hz). |
n |
filter order (no unit). |
a |
amplitude (linear scale, no unit). |
p |
initial phase (in radians). |
output |
character string, the class of the object to return, either
|
Details
The gammatone function in the time domain (impulse response) is
obtained with:
g(t) = a \times t^{n-1} \times e^{-2\pi \beta t} \times \cos(2 \pi cf t + \phi)
with a the amplitude, t time, n the filter order, cf the center frequency, \phi the initial phase.
The parameter \beta is the equivalent rectangular
bandwidth (ERB) bandwidth which varies according to the center
frequency cf following:
\beta = 24.7 \times (4.37 \times \frac{cf}{1000} + 1)
Value
A wave is returned. The class of the returned object is set with the argument output.
Note
Use the FFT based function, as spec or
meanspec, to get the filter in the frequency domain. See examples.
Author(s)
Jerome Sueur
References
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.
See Also
Examples
## 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)