dfDTW
calculates acoustic dissimilarity of dominant frequency contours using dynamic
time warping. Internally it applies the dtwDist
function from the dtw
package.
dfDTW(X = NULL, wl = 512, wl.freq = 512, length.out = 20, wn = "hanning", ovlp = 70,
bp = c(0, 22), threshold = 15, threshold.time = NULL, threshold.freq = NULL, img = TRUE,
parallel = 1, path = NULL, ts.df = NULL, img.suffix = "dfDTW", pb = TRUE,
clip.edges = TRUE, window.type = "none", open.end = FALSE, scale = FALSE,
frange.detec = FALSE, fsmooth = 0.1, ...)
A numeric vector of length 1 specifying the window length of the spectrogram, default is 512.
A numeric vector of length 1 specifying the window length of the spectrogram for measurements on the frecuency spectrum. Default is 512. Higher values would provide more accurate measurements.
A numeric vector of length 1 giving the number of measurements of dominant frequency desired (the length of the time series).
Character vector of length 1 specifying window name. Default is
"hanning". See function ftwindow
for more options.
Numeric vector of length 1 specifying % of overlap between two
consecutive windows, as in spectro
. Default is 70.
A numeric vector of length 2 for the lower and upper limits of a frequency bandpass filter (in kHz). Default is c(0, 22).
amplitude threshold (%) for dominant frequency detection. Default is 15.
amplitude threshold (%) for the time domain. Use for fundamental and dominant frequency detection. If NULL
(default) then the 'threshold' value is used.
amplitude threshold (%) for the frequency domain. Use for frequency range detection from the spectrum (see 'frange.detec'). If NULL
(default) then the
'threshold' value is used.
Logical argument. If FALSE
, image files are not produced. Default is TRUE
.
Numeric. Controls whether parallel computing is applied. It specifies the number of cores to be used. Default is 1 (i.e. no parallel computing). Not availble in Windows OS.
Character string containing the directory path where the sound files are located.
If NULL
(default) then the current working directory is used.
Optional. Data frame with time series of signals to be compared. If provided "X" is ignored.
A character vector of length 1 with a suffix (label) to add at the end of the names of
image files. Default is NULL
.
Logical argument to control progress bar. Default is TRUE
. Note that progress bar is only used
when parallel = 1.
Logical argument to control whether edges (start or end of signal) in
which amplitude values above the threshold were not detected will be removed. If
TRUE
(default) this edges will be excluded and signal contour will be calculated on the
remainging values. Note that DTW cannot be applied if missing values (e.i. when amplitude is not detected).
Logical. If TRUE
dominant frequency values are z-transformed using the scale
function, which "ignores" differences in absolute frequencies between the signals in order to focus the
comparison in the frequency contour, regardless of the pitch of signals. Default is TRUE
.
Logical. Controls whether frequency range of signal is automatically
detected using the frange.detec
function. If so, the range is used as the
bandpass filter (overwriting 'bp' argument). Default is FALSE
.
A numeric vector of length 1 to smooth the frequency spectrum with a mean
sliding window (in kHz) used for frequency range detection (when frange.detec = TRUE
). This help to average amplitude "hills" to minimize the effect of
amplitude modulation. Default is 0.1.
Additional arguments to be passed to trackfreqs
for customizing
graphical output.
A matrix with the pairwise dissimilarity values. If img is
FALSE
it also produces image files with the spectrograms of the signals listed in the
input data frame showing the location of the dominant frequencies.
This function extracts the dominant frequency values as a time series and
then calculates the pairwise acoustic dissimilarity using dynamic time warping.
The function uses the approx
function to interpolate values between dominant
frequency measures. If 'img' is TRUE
the function also produces image files
with the spectrograms of the signals listed in the input data frame showing the
location of the dominant frequencies.
specreator
for creating spectrograms from selections,
snrspecs
for creating spectrograms to
optimize noise margins used in sig2noise
and dfts
, ffts
, ffDTW
for frequency contour overlaid spectrograms.
https://marce10.github.io/2016/09/12/Similarity_of_acoustic_signals_with_dynamic_time_warping_(DTW).html
Other spectrogram creators: color.spectro
,
dfts
, ffDTW
,
ffts
, snrspecs
,
sp.en.ts
, specreator
,
trackfreqs
# NOT RUN {
{
# set the temp directory
setwd(tempdir())
#load data
data(list = c("Phae.long1", "Phae.long2","selec.table"))
writeWave(Phae.long2, "Phae.long2.wav") #save sound files
writeWave(Phae.long1, "Phae.long1.wav")
# run function
dfDTW(selec.table, length.out = 30, flim = c(1, 12), bp = c(2, 9), wl = 300)
}
# }
Run the code above in your browser using DataLab