Time measurements of a time wave

Share:

Description

This function computes and shows the duration of signal periods, pause periods and their ratio.

Usage

1
2
3
4
5
timer(wave, f, threshold = 5, dmin = NULL, envt="abs",
power = 1, msmooth = NULL, ksmooth = NULL,
ssmooth = NULL, tlim = NULL, plot = TRUE, plotthreshold = TRUE,
col = "black", colval = "red", 
xlab = "Time (s)", ylab = "Amplitude", ...)

Arguments

wave

an R object.

f

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

threshold

amplitude threshold for signal detection (in %).

dmin

time threshold (minimum duration) for signal detection (in s).

envt

the type of envelope to be used: either "abs" for absolute amplitude envelope or "hil" for Hilbert amplitude envelope. See env.

power

a power factor applied to the amplitude envelope. Increasing power will reduce low amplitude modulations and increase high amplide modulations. This can be used to reduce background noise (by default equals to 1, i.e. no change.

msmooth

a vector of length 2 to smooth the amplitude envelope with a mean sliding window. The first component is the window length (in number of points). The second component is the overlap between successive windows (in %). See env.

ksmooth

kernel smooth for the amplitude enveloppe via kernel. See env.

ssmooth

sum smooth for the amplitude enveloppe. See env.

tlim

modifications of the time X-axis limits.

plot

logical, if TRUE plots the envelope and the measurements (by default TRUE).

plotthreshold

logical, if TRUE plots the threshold as an horizontal line on the graph (by default TRUE).

col

colour of the envelope.

colval

colour of plotted measurements.

xlab

title of the x-axis.

ylab

title of the y-axis.

...

other plot graphical parameters.

Value

A list containing seven items:

s

duration of signal period(s) in seconds

p

duration of pause period(s) in seconds

r

ratio between the signal and silence periods(s)

positions

a list containing four elements:

s.start

start position(s) of signal period(s)

s.end

end position(s) of signal period(s)

first

whether the first event detected is a pause or a signal

Warning

Setting to high values to msmooth or ssmooth might return unaccurate results. Double check your results if so.

Author(s)

Jerome Sueur

See Also

env, cutw, pastew.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(tico)
timer(tico,f=22050,threshold=5,msmooth=c(50,0))
# to compare with an oscillographic representation
data(orni)
op<-par(mfrow=c(2,1))
timer(orni,f=22050,threshold=5,msmooth=c(40,0),tck=0.05,
        bty="l",colval="blue")
title(main="A cicada song made of five echemes",col="blue")
oscillo(orni,f=22050,k=1,j=1)
par(op)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.