Learn R Programming

phonTools (version 0.2-1.1)

loadsound: Load WAV files into R

Description

A function which allows WAV files to be loaded into R.

Usage

loadsound (filename)

Arguments

filename
A string indicating the file name of the WAV file to be loaded. If no filename is provided, a dialog box will open allowing the user to select a file.

Value

  • An object of class 'sound', a list containing the elements:
  • filenameA vector containing the filename of the WAV file.
  • fsThe sampling frequency of the sound.
  • durationThe duration of the sound, in milliseconds.
  • soundA vector of numeric values representing the sampled sound.

Details

The function is only compatible with 8 and 16 bit WAV files. Only mono WAV files are supported. The function returns a 'sound object'. Many of the functions included in this package interact with 'sound' objects, for example, when 'sound' objects are passed to certain functions, sampling frequencies do not need to be specified.

References

https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

Examples

Run this code
## Use the command below to select a WAV file to load into R
## sound = loadsound ()

## sound
## plot (sound)
## spectrogram (sound, pause = FALSE)

Run the code above in your browser using DataLab