Learn R Programming

seewave (version 1.5.5)

dfreq: Dominant frequency of a time wave

Description

This function gives the dominant frequency (i. e. the frequency of highest amplitude) of a time wave.

Usage

dfreq(wave, f, wl = 512, wn = "hanning", ovlp = 0, threshold = NULL,
plot = TRUE, xlab = "Times (s)", ylab = "Frequency (kHz)",
ylim = c(0, f/2000), type ="l",...)

Arguments

wave
a vector, a matrix (first column), an object of class ts, Sample (left channel), or Wave (left channel).
f
sampling frequency of wave (in Hz). Does not need to be specified if wave is an object of class ts, Sample, or Wave<
wl
length of the window for the analysis (even number of points, by default = 512).
wn
window name, see ftwindow (by default "hanning").
ovlp
overlap between two successive analysis windows (in % ).
threshold
amplitude threshold for signal detection (in % ).
plot
logical, if TRUE plots the dominant frequency against time (by default TRUE).
xlab
title of the x axis.
ylab
title of the y axis.
ylim
the range of y values.
type
if plot is TRUE, type of plot that should be drawn. See plot for details (by default "l" for lines).
...
other plot graphical parameters.

Value

  • 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).

See Also

spec, meanspec,spectro.

Examples

Run this code
data(tico)
dfreq(tico,f=22050,ovlp=50,threshold=5)
# overlay on spectrogram
spectro(tico,f=22050,ovlp=50,zp=16,scale=FALSE,
    collevels=seq(-40,0,1),palette=rev.terrain.colors)
par(new=TRUE,las=1)
dfreq(tico,f=22050,ovlp=50,threshold=6,col="red",lwd=2,
    ann=FALSE)

Run the code above in your browser using DataLab