audioSample: Audio sample class and constructor

View source: R/api.R

audioSampleR Documentation

Audio sample class and constructor

Description

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:

  • ratesample rate (in Hz), mandatory

  • bitsresolution of the source (in bits), optional

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.

Usage

  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, ...)

Arguments

x

object to convert or initilize with

rate

sample rate

bits

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

clip

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

Value

audioSample and as.audioSample return an audio sample object.

Examples

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

play(x)


audio documentation built on Aug. 18, 2023, 9:07 a.m.

Related to audioSample in audio...