align.wave {SoundShape} | R Documentation |
Automatic placement of calls at beggining of sound window
Description
Recreate each ".wav"
file on a given folder while placing calls at the beginning of sound window. New ".wav"
files will be stored on a new folder, which is automatically created.
Usage
align.wave(
wav.at = NULL,
wav.to = "Aligned",
time.length = 1,
time.perc = 0.005,
flim = NULL,
dBlevel = 25,
f = 44100,
wl = 512,
ovlp = 70
)
Arguments
wav.at |
filepath to the folder where |
wav.to |
name of the folder where new |
time.length |
intended length for the time (X-axis) in seconds. Should be a value that encompasses all sounds in the study. By default: |
time.perc |
slight time gap (in percentage) relative to the intended length that encompass all sounds in the study (i.e. |
flim |
modifications of the frequency limits (Y-axis) to focus on acoustic units. Useful for recordings with low signal-to-noise ratio. Vector with two values in kHz. By default: |
dBlevel |
absolute amplitude value to be used as relative amplitude contour, which will serve as reference for call placement. By default: |
f |
sampling frequency of |
wl |
length of the window for the analysis. By default: |
ovlp |
overlap between two successive windows (in %) for increased spectrogram resolution. By default: |
Author(s)
Pedro Rocha
References
MacLeod, N., Krieger, J. & Jones, K. E. (2013). Geometric morphometric approaches to acoustic signal analysis in mammalian biology. Hystrix, the Italian Journal of Mammalogy, 24(1), 110-125.
Rocha, P. & Romano, P. (2021) The shape of sound: A new R
package that crosses the bridge between Bioacoustics and Geometric Morphometrics. Methods in Ecology and Evolution, 12(6), 1115-1121.
See Also
Useful links:
Examples
library(seewave)
library(tuneR)
# Create temporary folder to store ".wav" files
wav.at <- file.path(base::tempdir(), "align.wave")
if(!dir.exists(wav.at)) dir.create(wav.at)
# Create temporary folder to store results
store.at <- file.path(base::tempdir(), "align.wave-output")
if(!dir.exists(store.at)) dir.create(store.at)
# Select acoustic units to be analyzed
data(cuvieri)
spectro(cuvieri, flim = c(0,3)) # Visualize sound data that will be used
# Cut acoustic units from original Wave
cut.cuvieri1 <- cutw(cuvieri, f=44100, from=0, to=0.5, output = "Wave")
cut.cuvieri2 <- cutw(cuvieri, f=44100, from=0.7, to=1.2, output = "Wave")
cut.cuvieri3 <- cutw(cuvieri, f=44100, from=1.4, to=1.9, output = "Wave")
# Export ".wav" files containing selected acoustic units and store on previosly created folder
writeWave(cut.cuvieri1, filename = file.path(wav.at, "cut.cuvieri1.wav"), extensible = FALSE)
writeWave(cut.cuvieri2, filename = file.path(wav.at, "cut.cuvieri2.wav"), extensible = FALSE)
writeWave(cut.cuvieri3, filename = file.path(wav.at, "cut.cuvieri3.wav"), extensible = FALSE)
# Align acoustic units selected at 1% of time lenght
align.wave(wav.at = wav.at, wav.to = "Aligned",
time.length = 0.5, time.perc = 0.01, dBlevel = 25)
# Verify alignment using eigensound function featuring analysis.type = "twoDshape"
eigensound(analysis.type = "twoDshape", wav.at = file.path(wav.at, "Aligned"), store.at = store.at,
flim=c(0, 3), tlim=c(0,0.5), dBlevel = 25, plot.exp = TRUE, plot.as = "jpeg")
# To see jpeg files created, check folder specified by store.at