audioSample {audio}R Documentation

Audio sample class and constructor


audioSample is a class encapsulating digitalized (sampled) audio data. Essentiually it tags numeric vectors and matrices with additional audio information (most importantly sample rate).

audioSample is the designated constructor of such objects.

Instances of the audioSample are numeric vectors or matrices with the following additional attributes:

If the object itself is a vector, it contains only one channel. Otherwise it is a matrix with as many rows as there are channels (hence 2 for stereo).

as.audioSample generic converts an object into an audio sample object. The default method is very similar to the constructor except that it attempts to infer the parameters from the object's attributes if they are not specified. Thus they are optional although they don't have visible defaults.


  audioSample(x, rate=44100, bits=16, clip = TRUE)
  as.audioSample(x, ...)
  ## Default S3 method:
as.audioSample(x, rate, bits, clip, ...)
  ## S3 method for class 'Sample'
as.audioSample(x, ...)



object to convert or initilize with


sample rate


resolution of the source. It doesn't affect the data itself and is only used for playback and export.


boolean value determining whether the source should be clipped to a range between -1 and 1. Values outside this range result in undefined behavior.


parameters passed to the object-specific method


audioSample and as.audioSample return an audio sample object.


x <- audioSample(sin(1:8000/10), 8000)


[Package audio version 0.1-7 Index]