import_audio {soundClass} | R Documentation |
Import a recording
Description
Import a "wav" recording. If the recording is stereo it is converted to mono by keeping the channel with overall higher amplitude
Usage
import_audio(path, butt = TRUE, low, high, tx = 1)
Arguments
path |
Character. Full path to the recording |
butt |
Logical. If TRUE filters the recording with a 12th order filter. The filter is applied twice to better cleaning of the recording |
low |
Minimum frequency in kHz for the butterworth filter |
high |
Maximum frequency in kHz for the butterworth filter |
tx |
Time expanded. Only used in recorders specifically intended for bat recordings. Can take the values "auto" or any numeric value. If the recording is not time expanded tx must be set to 1 (the default). If it's time expanded the numeric value corresponding to the time expansion should be indicated or "auto" should be selected. If tx = "auto" the function assumes that sampling rates < 50kHz corresponds to tx = 10 and > 50kHz to tx = 1. |
Value
An object of class "rc". This object is a list with the following components:
sound_samples – sound samples of the recording
file_name – name of the recording
file_time – time of modification of the file (indicated for Pettersson Elektronic detectors, for other manufactures creation time should be preferable but it's not implemented yet)
fs – sample frequency
tx – expanded time factor
Author(s)
Bruno Silva
Examples
# Create a sample wav file in a temporary directory
recording <- tuneR::sine(440)
temp_dir <- tempdir()
rec_path <- file.path(temp_dir, "recording.wav")
tuneR::writeWave(recording, filename = rec_path)
# Import the sample wav file
new_rec <- import_audio(rec_path, low = 1, high = 20, tx = 1)
new_rec
file.remove(rec_path)