This function estimates the surface difference between two amplitude envelopes.
diffenv(wave1, wave2, f, channel = c(1,1), envt = "hil", msmooth = NULL, ksmooth = NULL,
plot = FALSE, lty1 = 1, lty2 = 2, col1 = 2, col2 = 4, cold = 8,
xlab = "Time (s)", ylab = "Amplitude", ylim = NULL, legend = TRUE, ...)
a first R object.
a second R object.
sampling frequency of wave
(in Hz). Does not need to
be specified if embedded in wave
.
channel of the R objects, by default left channel (1) for each object.
the type of envelope to be used: either "abs" for absolute
amplitude envelope or "hil" for Hilbert amplitude envelope. See env
.
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
.
logical, if TRUE
plots both envelopes and their surface
difference (by default FALSE
).
line type of the first envelope (envelope of wave1
).
line type of the second envelope (envelope of wave2
).
colour of the first envelope (envelope of wave1
).
colour of the second envelope (envelope of wave2
).
colour of the surface difference.
title of the time axis.
title of the amplitude axis.
range of amplitude axis.
logical, if TRUE
adds a legend to the plot.
other plot
graphical parameters.
The difference is returned. This value is without unit.
When plot
is TRUE
, both envelopes and their difference surface are
plotted on the same graph.
D is a Manhattan distance (l1 norm).
Envelopes of both waves are first transformed as probability mass functions (PMF).
Envelope difference is then computed according to:
Sueur, J., Pavoine, S., Hamerlynck, O. & Duvail, S. (2008) - Rapid acoustic survey for biodiversity appraisal. PLoS ONE, 3(12): e4065.
# NOT RUN {
data(tico) ; tico <- tico@left
data(orni) ; orni <- orni@left
# selection in tico of two waves with similar duration
tico2<-tico[1:length(orni)]
diffenv(tico2,orni,f=22050,plot=TRUE)
# smoothing the envelope gives a better graph but slightly changes the result
diffenv(tico2,orni,f=22050,msmooth=c(20,0),plot=TRUE)
# }
Run the code above in your browser using DataLab