zc: Instantaneous frequency of a time wave by zero-crossing

View source: R/seewave.r

zcR Documentation

Instantaneous frequency of a time wave by zero-crossing

Description

This function measures the period of a full oscillating cycle.

Usage

zc(wave, f, channel = 1,  plot = TRUE, interpol = 1, threshold = NULL,
xlab = "Time (s)", ylab = "Frequency (kHz)", ylim = c(0, f/2000),
warning = TRUE, ...)

Arguments

wave

an R object.

f

sampling frequency of wave (in Hz). Does not need to be specified if embedded in wave.

channel

channel of the R object, by default left channel (1).

plot

logical, if TRUE plots the dominant frequency along the time wave(by default TRUE).

interpol

a numeric vector of length 1, interpolation factor.

threshold

amplitude threshold for signal detection (in % ).

xlab

title of the x axis.

ylab

title of the y axis.

ylim

the range of y values.

warning

a logial to specify if warning message should be displayed or not when interpol is > 100.

...

other plot graphical parameters.

Details

If plot is FALSE, zc returns a vector of numeric data with the instantaneous frequency.

Value

If plot is FALSE, zc returns a two-column matrix, the first column corresponding to time in seconds (x-axis) and the second column corresponding to the instantaneous frequency of the time wave in kHz (y-axis).
‘NA’s correspond either to pause periods (e. g. detected applying threshold) or sections of the time wave not crossing the zero line. To remove ‘NA’s with na.omit allows to get only instantaneous frequency values but discards information about pause sections.

Note

interpol adds points to the time wave by linear interpolation (through approx). This increases measurement precision but as well time process. Type argument of plot cannot be set to “l”.

Author(s)

Jerome Sueur sueur@mnhn.fr, Caroline Simonis and Thierry Aubin

References

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

See Also

zc, ifreq

Examples

data(pellucens)
pellu1 <- cutw(pellucens,f=22050,from=0,to=1,plot=FALSE)
# without interpolation
zc(pellu1,f=22050,threshold=5,pch=20)
# with interpolation
zc(pellu1,f=22050,threshold=5,interpol=20,pch=20)
# a way to plot with a line and to filter low frequencies
pellu2 <- zc(pellu1,f=22050,threshold=5,interpol=20,plot=FALSE)
pellu3 <- na.omit(pellu2[,2])
pellu4 <- pellu3[pellu3>3]
plot(x=seq(0,nrow(pellu1)/22050,length.out=length(pellu4)),
    y=pellu4,type="l",xlab="Time(s)",ylab="Frequency(kHz)")

seewave documentation built on Oct. 19, 2023, 5:07 p.m.

Related to zc in seewave...