fix_wavs | R Documentation |
fix_wavs
fixes sound files in .wav format so they can be imported into R.
fix_wavs(
checksels = NULL,
files = NULL,
samp.rate = NULL,
bit.depth = NULL,
path = NULL,
mono = FALSE
)
checksels |
Data frame with results from |
files |
Character vector with the names of the .wav files to fix. Default is |
samp.rate |
Numeric vector of length 1 with the sampling rate (in kHz) for output files. Default is |
bit.depth |
Numeric vector of length 1 with the dynamic interval (i.e. bit depth) for output files.
Default is |
path |
Character string containing the directory path where the sound files are located.
If |
mono |
Logical indicating if stereo (2 channel) files should be converted to mono (1 channel). Default is |
This function aims to simplify the process of converting sound files that cannot be imported into R and/or homogenizing sound files. Problematic files can be determined using check_sound_files
or check_sels
. The
check_sels
output can be directly input using the argument 'checksels'. Alternatively a vector of file
names to be "fixed" can be provided (argument 'files'). If neither of those 2 are provided the function will convert
all .wav sound files in the working directory to the specified sample rate/bit depth. Files are saved in a new directory
('converted_sound_files'). Internally the function calls SOX (SOX must be installed). If both 'checksels' and 'files' are NULL
then all files in 'path' are converted. Note that it only fixes/convert sound files in .wav format.
A folder inside the working directory (or path provided) all 'converted_sound_files', containing sound files in a format that can be imported in R.
Marcelo Araya-Salas (marcelo.araya@ucr.ac.cr)
Araya-Salas, M., & Smith-Vidaurre, G. (2017). warbleR: An R package to streamline analysis of animal acoustic signals. Methods in Ecology and Evolution, 8(2), 184-191.
## Not run:
# Load example files and save to temporary working directory
data(list = c("Phae.long1", "Phae.long2", "Phae.long3", "Phae.long4", "lbh_selec_table"))
writeWave(Phae.long1, file.path(tempdir(), "Phae.long1.wav"))
writeWave(Phae.long2, file.path(tempdir(), "Phae.long2.wav"))
writeWave(Phae.long3, file.path(tempdir(), "Phae.long3.wav"))
writeWave(Phae.long4, file.path(tempdir(), "Phae.long4.wav"))
fix_wavs(files = lbh_selec_table$sound.files, path = tempdir())
# check this folder
tempdir()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.