Learn R Programming

tuneR (version 0.2-6)

WaveIO: Reading and writing Wave files

Description

Reading and writing Wave files.

Usage

readWave(filename, from = 1, to = Inf, 
    units = c("samples", "seconds", "minutes", "hours"), header = FALSE)
writeWave(object, filename)

Arguments

filename
Filename of the file to be read or written.
from
where to start reading (in order to save memory by reading wave file piecewise), in units.
to
where to stop reading (in order to save memory by reading wave file piecewise), in units.
units
units in which from and to is given, the default is samples, but can be set to time intervals such as seconds, see the Usage Section above.
header
if TRUE, just header information of the Wave file are returned, otherwise (the default) the whole Wave object.
object
Object of class Wave to be written to a Wave file.

Value

  • readWave returns an object of class Wave or a list containing just the header information if header = TRUE. writeWave creates a Wave file, but returns nothing.

concept

  • Wave
  • file
  • sound
  • music
  • speech

See Also

Wave, normalize

Examples

Run this code
Wobj <- sine(440, bit = 16)

tdir <- tempdir()
tfile <- file.path(tdir, "myWave.wav")
writeWave(Wobj, filename = tfile)
list.files(tdir, pattern = "\.wav$")
newWobj <- readWave(tfile)
newWobj
file.remove(tfile)

Run the code above in your browser using DataLab