X: object of class 'extended_selection_table' created by the function selection_table from the warbleR package. The object must include the following additional columns: 'sound.id', 'bottom.freq' and 'top.freq'.
Y: object of class 'extended_selection_table' (a class created by the function selection_table from the warbleR package) with the master sound file annotations. This should be the same data than that was used for finding the position of markers in find_markers. It should also contain a 'sound.id' column.
cores: Numeric vector of length 1. Controls whether parallel computing is applied by specifying the number of cores to be used. Default is 1 (i.e. no parallel computing). Can be set globally for the current R session via the "mc.cores" option (see options).
pb: Logical argument to control if progress bar is shown. Default is TRUE. Can be set globally for the current R session via the "pb" option (see options).
hop.size: A numeric vector of length 1 specifying the time window duration (in ms). Default is 11.6 ms, which is equivalent to 512 wl for a 44.1 kHz sampling rate. Ignored if 'wl' is supplied. Can be set globally for the current R session via the "hop.size" option (see options).
wl: a vector with a single even integer number specifying the window length of the spectrogram, default is NULL. If supplied, 'hop.size' is ignored. Odd integers will be rounded up to the nearest even number. Can be set globally for the current R session via the "wl" option (see options).
ovlp: Numeric vector of length 1 specifying the percentage of overlap between two consecutive windows, as in spectro. Default is 90. High values slow down the function but produce more accurate results. Can be set globally for the current R session via the "ovlp" option (see options).
wn: A character vector of length 1 specifying the window name as in ftwindow.
Returns
Object 'X' in which time parameters (columns 'start' and 'end') have been tailored to more closely match the start and end of the reference sound.
Details
Precise alignment is crucial for downstream measures of sound degradation. This function uses spectrographic cross-correlation to align the position in time of test sounds. The master sound file is used as reference. The function calls warbleR's cross_correlation internally to align sounds using cross-correlation. The output extended selection table contains the new start and end values after alignment. Note that this function only works to further improve alignments if the estimated position of the test sound is already close to the actual position. Note that both 'X' and 'Y' must be extended selection tables sensu selection_table.
Examples
{# load example data data("test_sounds_est") data("master_est")# create "unaligned_test_sounds_est" by# adding error to "test_sounds_est" start and end unaligned_test_sounds_est <- test_sounds_est
set.seed(123) noise_time <- sample(c(0.009,-0.01,0.03,-0.03,0,0.07,-0.007), nrow(unaligned_test_sounds_est), replace =TRUE) attr(unaligned_test_sounds_est,"check.res")$start <- unaligned_test_sounds_est$start <- unaligned_test_sounds_est$start + noise_time
attr(unaligned_test_sounds_est,"check.res")$end <- unaligned_test_sounds_est$end <- unaligned_test_sounds_est$end + noise_time
# re alignrealigned_est <- auto_realign(X = unaligned_test_sounds_est, Y = master_est)}
References
Araya-Salas M., E. Grabarczyk, M. Quiroz-Oliva, A. Garcia-Rodriguez, A. Rico-Guevara. (2023), baRulho: an R package to quantify degradation in animal acoustic signals .bioRxiv 2023.11.22.568305.
Clark, C.W., Marler, P. & Beeman K. (1987). Quantitative analysis of animal vocal phonology: an application to Swamp Sparrow song. Ethology. 76:101-115.
See Also
blur_ratio, cross_correlation
Other test sound alignment: align_test_files(), find_markers(), manual_realign(), plot_aligned_sounds()