| meanspec | R Documentation |
This function returns the mean frequency spectrum (i.e. the mean relative amplitude of the frequency distribution) of a time wave. Results can be expressed either in absolute or dB data.
meanspec(wave, f, channel = 1, wl = 512, wn = "hanning", ovlp = 0, fftw = FALSE,
norm = TRUE, PSD = FALSE, PMF = FALSE, FUN = mean, correction = "none", dB = NULL,
dBref = NULL, from = NULL, to = NULL, identify = FALSE,
col = "black", cex = 1, plot = 1, flab = "Frequency (kHz)",
alab = "Amplitude", flim = NULL, alim = NULL, type ="l", ...)
wave |
an R object. |
f |
sampling frequency of |
channel |
channel of the R object, by default left channel (1). |
wl |
length of the window for the analysis (even number of points, by default = 512). |
wn |
window name, see |
ovlp |
overlap between two successive analysis windows (in %). |
fftw |
if |
norm |
if |
PSD |
if |
PMF |
if |
FUN |
the function to apply on the rows of the STFT matrix, by
default |
correction |
a character vector of length 1 to apply an
amplitude ("amplitude") or an energy ("energy") correction
to the FT window. This argument is useful only when one wish to obtain
absolute values that is when |
dB |
a character string specifying the type dB to return: "max0" for a maximum dB value at 0, "A", "B", "C", "D", and "ITU" for common dB weights. |
dBref |
a dB reference value when |
from |
start mark where to compute the spectrum (in s). |
to |
end mark where to compute the spectrum (in s). |
identify |
to identify frequency and amplitude values on the plot with the help of a cursor. |
col |
colour of the spectrum. |
cex |
pitch size. |
plot |
if |
flab |
title of the frequency axis. |
alab |
title of the amplitude axis. |
flim |
range of frequency axis (in kHz). |
alim |
range of amplitude axis. |
type |
if |
... |
other |
See examples of spec. This function is based on fft.
If plot is FALSE, meanspec returns a two columns matrix,
the first column corresponding to the frequency axis, the second column
corresponding to the amplitude axis.
If identify is TRUE, spec returns a list with
two elements:
freq |
the frequency of the points chosen on the spectrum |
amp |
the relative amplitude of the points chosen on the spectrum |
The argument peaks is no more available
(version > 1.5.6). See the function fpeaks
for peak(s) detection.
The argument fftw can be used to try to speed up process
time. When set to TRUE, the Fourier transform is computed
through the function FFT of the package fftw. This package is a
wrapper around the fastest Fourier transform of the free C subroutine
library FFTW (http://www.fftw.org/). FFT should be then installed on your OS.
Jerome Sueur sueur@mnhn.fr
spec,fpeaks,
localpeaks, dynspec,
corspec, diffspec, simspec, fft.
data(orni)
# compute the mean spectrum of the whole time wave
meanspec(orni,f=22050)
# compute the mean spectrum of a time wave section (from 0.32 s to 0.39 s)
meanspec(orni,f=22050,from=0.32,to=0.39)
# different window lengths
op<-par(mfrow=c(3,1))
meanspec(orni,f=22050,wl=256)
title("wl=256")
meanspec(orni,f=22050,wl=1024)
title("wl=1024")
meanspec(orni,f=22050,wl=4096)
title("wl=4096")
par(op)
# different overlap values (almost no effects here...)
op<-par(mfrow=c(3,1))
meanspec(orni,f=22050)
title("ovlp=0")
meanspec(orni,f=22050,ovlp=50)
title("ovlp=50")
meanspec(orni,f=22050,ovlp=95)
title("ovlp=95")
par(op)
# use of flim to zoom in
op<-par(mfrow=c(2,1))
meanspec(orni,f=22050)
title("zoom in")
meanspec(orni,f=22050,wl=512,flim=c(4,6))
par(op)
# comparaison of spectrum and mean spectrum
op<-par(mfrow=c(2,1))
spec(orni,f=22050)
title("spec()")
meanspec(orni,f=22050)
title("meanspec()")
par(op)
# log scale on frequency axis
meanspec(orni, f=22050, log="x")
# median spectrum
meanspec(orni,f=22050, FUN=median)
# variance spectrum
meanspec(orni,f=22050, FUN=var)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.