align.wave: Automatic placement of calls at beggining of sound window

Description Usage Arguments Author(s) References See Also Examples

View source: R/align.wave.R

Description

Recreate each ".wav" file on a given folder while placing calls at the beggining of sound window. New ".wav" files will be stored on a new folder, which is automatically created.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
align.wave(
  wav.at = NULL,
  wav.to = "Aligned",
  time.length = 1,
  time.perc = 0.005,
  dBlevel = 25,
  f = 44100,
  wl = 512,
  ovlp = 70
)

Arguments

wav.at

filepath to the folder where ".wav" files are stored. Should be presented between quotation marks. By default: wav.at = NULL (i.e. user must specify the filepath to ".wav" files)

wav.to

name of the folder where new ".wav" files will be stored. Should be presented between quotation marks. By default: wav.to = "Aligned"

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.length = 1

time.perc

slight time gap (in percentage) relative to the intended length that encompass all sounds in the study (i.e. time.length). Intervals are added before and after the minimum and maximum time coordinates (X-values) from the selected curve of relative amplitude (dBlevel). By default: time.perc = 0.005 (i.e. 0.5%)

dBlevel

absolute amplitude value to be used as relative amplitude contour, which will serve as reference for call placement. By default: dBlevel = 25

f

sampling frequency of ".wav" files (in Hz). By default: f = 44100

wl

length of the window for the analysis. By default: wl = 512

ovlp

overlap between two successive windows (in %) for increased spectrogram resolution. By default: ovlp = 70

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. (in prep) The shape of sound: A new R package that crosses the bridge between Bioacoustics and Geometric Morphometrics. Methods in Ecology and Evolution

See Also

eigensound

Useful links:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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

p-rocha/SoundShape documentation built on April 8, 2021, 5:55 a.m.