Skip to contents

Managing audio in R with SonicScrewdriveR

Reading audio files

Several functions are available to read audio files into R, including the readWave() and readMP3() functions from the tuneR package, as well as tools from the package av. SonicScrewdriveR simplifies reading audio files by providing a single wrapper for these functions, read_audio(), which can read audio files in a variety of formats, including WAV, MP3, and FLAC.

filename <- system.file("extdata", "AUDIOMOTH.WAV", package="sonicscrewdriver")
w <- readAudio(filename)

Performing analyses on channels

Some existing functions only operate on a single channel at a time. This may cause unnecessarily complex workflows when bulk analysing files with different numbers of channels. The allChannels() function applies a function to each channel and returns a list of analyses. This technique allows for the same analysis to be performed on each channel, without reference to the number of channels in the audio file. Optionally, a cluster can be specified to process channels on separate processor cores to increase analysis speed.

Windowing

It is often desirable to process a long audio file in chunks. The windowing() function can be used to split an audio file into overlapping or non-overlapping windows. This function may be particularly useful for processing long Wave files in a memory-efficient manner. Optionally, a cluster can be specified to process windows on separate processor cores to increase processing speed.

PseudoWave objects

TaggedWave workflow

The techniques above can be applied to the generic Wave and WaveMC objects from the tuneR package.

The TaggedWave class extends the Wave class from the tuneR package so that it can include extended metadata and the results of analyses. This allows for the storage of additional information about the audio file, such as the location and time of recording, and the results of analyses. The tagWave() function can be used to tag a Wave or WaveMC object with additional metadata.

In addition, combined with new classes WaveAugment, WaveFilter, and WaveAnalyse it is possible to create a self-documenting pipeline for audio processing and analysis (that is also compatible with the R pipe).