Learn R Programming

seewave (version 1.5.2)

autoc: Short-term autocorrelation of a time wave

Description

This function returns the fundamental frequency of a harmonic time wave. This is achieved by computing a correlation of the signal with itself after a time delay.

Usage

autoc(wave, f, wl = 512, fmax, threshold = NULL, plot = TRUE,
xlab = "Time (s)", ylab = "Frequency (kHz)", ylim = c(0, f/2000),...)

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).
fmax
the maximum frequency to detect (in Hz).
threshold
amplitude threshold for signal detection (in %).
plot
logical, if TRUE plots the fundamental frequency against time (by default TRUE).
xlab
title of the x-axis.
ylab
title of the y-axis.
ylim
the range of y values.
...
other plot graphical parameters.

Value

  • When plot is FALSE, autoc returns a two-column matrix, the first column corresponding to time in seconds (x-axis) and the second column corresponding to to fundamental frequency in kHz (y-axis). NA corresponds to pause sections in wave (see threshold).

Details

Autocorrelation process can be time consuming.

References

Hopp, S. L., Owren, M. J. and Evans, C. S. (Eds) 1998. Animal acoustic communication. Springer, Berlin, Heidelberg.

See Also

ceps

Examples

Run this code
data(sheep)
# fundamental frequency of a sheep
autoc(sheep,f=8000,threshold=5,fmax=700)
# overlay on spectrogram
spectro(sheep,f=8000,ovlp=75,zp=16,scale=FALSE)
par(new=TRUE)
autoc(sheep,f=8000,wl=512,threshold=5,fmax=700,col="black",pch=20,
    xaxs="i",yaxs="i",ann=FALSE,yaxt="n")
legend(0.5,3.6,"Fundamental frequency",pch=20,col="black",bty=0,cex=0.7)

Run the code above in your browser using DataLab