Skip to contents

read_wave is a wrapper for tuneR's readWave function that read sound files listed in data frames and selection tables


read_wave(X, index, from = X$start[index], to = X$end[index], channel = NULL,
header = FALSE, path = NULL)



'data.frame', 'selection_table' or 'extended_selection_table' containing columns for sound file name (sound.files), selection number (selec), and start and end time of signals (start and end). Alternatively, the name of a '.wav' file or URL address to a '.wav' or '.mp3' file can be provided. The file name can contain the directory path. 'top.freq' and 'bottom.freq' columns are optional. Default is NULL.


Index of the selection in 'X' that will be read. Ignored if 'X' is NULL.


Where to start reading, in seconds. Default is X$start[index].


Where to stop reading, in seconds. Default is X$end[index]. Inf can be used for reading the entire sound file (when 'X' is a sound file name),


Channel to be read from sound file (1 = left, 2 = right, or higher number for multichannel waves). If NULL (default) or higher than the number of channels in a wave then the first channel is used. Only applies to '.wav' files in local directories.


If TRUE, only the header information of the Wave object is returned, otherwise (the default) the whole Wave object.


Character string containing the directory path where the sound files are located. If NULL (default) then the current working directory is used. If 'X' refers to a sound file including its directory 'path' is ignored.


An object of class "Wave".


The function is a wrapper for readWave that read sound files listed within selection tables. It is also used internally by warbleR functions to read wave objects from extended selection tables (see selection_table for details).


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.


Marcelo Araya-Salas (


  # write wave files with lower case file extension
  data(list = c("Phae.long1"))
  writeWave(Phae.long1, file.path(tempdir(), "Phae.long1.wav"))

  # read from selection table
  read_wave(X = lbh_selec_table, index = 1, path = tempdir())

  # from extended selection table
  read_wave(X = lbh.est, index = 1)

  # read WAV
  filepath <- system.file("extdata", "recording.wav", package = "bioacoustics")

  # read MP3
  filepath <- system.file("extdata", "recording.mp3", package = "bioacoustics")

  # URL file
  read_wave(X = "")
#> Wave Object
#> 	Number of Samples:      274176
#> 	Duration (seconds):     6.22
#> 	Samplingrate (Hertz):   44100
#> 	Channels (Mono/Stereo): Mono
#> 	PCM (integer format):   TRUE
#> 	Bit (8/16/24/32/64):    16