dfreq | R Documentation |
This function gives the dominant frequency (i. e. the frequency of highest amplitude) of a time wave.
dfreq(wave, f, channel = 1, wl = 512, wn = "hanning", ovlp = 0, fftw= FALSE, at =
NULL, tlim = NULL, threshold = NULL, bandpass = NULL, clip = NULL,
plot = TRUE, xlab = "Times (s)", ylab = "Frequency (kHz)",
ylim = c(0, f/2000), ...)
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 |
at |
time position where the dominant frequency has to be computed (in s.). |
tlim |
modifications of the time X-axis limits. |
threshold |
amplitude threshold for signal detection (in % ). |
bandpass |
a numeric vector of length two, giving the lower and upper limits of a frequency bandpass filter (in Hz). |
clip |
a numeric value to select dominant frequency values according to their amplitude in reference to a maximal value of 1 for the whole signal (has to be >0 & < 1). |
plot |
logical, if |
xlab |
title of the x axis. |
ylab |
title of the y axis. |
ylim |
the range of y values. |
... |
other |
When plot
is FALSE
, dfreq
returns a two-column matrix, the first column corresponding to time in seconds (x-axis) and the second column corresponding to
to dominant frequency in kHz (y-axis).
NA corresponds to pause sections in wave
(see threshold
).
This function is based on fft
.
Jerome Sueur sueur@mnhn.fr
spec
, meanspec
,spectro
.
data(tico)
f <- 22050
# default
dfreq(tico,f)
# using the amplitude threshold and changing the graphical output
dfreq(tico, f, ovlp=50,threshold=5, type="l", col=2)
# using 'at' argument for specific positions along the time axis
dfreq(tico, f, at=c(0.25, 0.75, 1.2, 1.6))
dfreq(tico, f, at=seq(0.5, 1.4, by=0.005), threshold=5)
# a specific number of measures on a single note
dfreq(tico, f, at=seq(0.5, 0.9, len=100), threshold=5, xlim=c(0.5,0.9))
# overlap on spectrogram
# and use of 'clip' argument to better track the dominant frequency
# in noisy conditions
op <- par()
ticon <- tico@left/max(tico@left) + noisew(d=length(tico@left)/f, f)
spectro(ticon, f)
res <- dfreq(ticon, f, clip=0.3, plot=FALSE)
points(res, col=2, pch =13)
par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.