sound: The Waveform Matrix of a Sample Object

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/sound.R

Description

Get or set the waveform matrix of a Sample object or a wav file.

Usage

1
2
sound(s)
sound(s) <- value

Arguments

s

a Sample object, or a string giving the name of a wav file.

value

a channels(s) x sampleLength(s) matrix of doubles.

Details

The replacement form can be used to reset the waveform of a sample object. Here, filenames are not accepted for codes.

The matrix can have one (for mono samples) or two rows (for stereo samples), where in the latter case the first row corresponds to the left and the second row to the right channel.

It contains the waveform(s) of the Sample object as sequence(s) of numbers between -1 and 1. waveform can contain arbitrary real numbers, but when the Sample object is played or saved to disk, [-1,1] is regarded as the native range of the sample, and any values outside this interval will cause cracks in the sound.

The waveform of a Sample object might exceed this interval during calculations. It is the task of the programmer to take care about the range of the waveform before saving or playing the sample, for example by using the normalize function.

Value

the waveform matrix of the sample.

Author(s)

Author: Matthias Heymann <mail@MatthiasHeymann.de>

Maintainer: Stefan Langenberg <langenberg@uni-bonn.de>

See Also

as.Sample

Examples

1
2
3
4
5
6
## Not run: 
s <- Sine(440,1,channels=2)  # stereo sine wave
sound(s)[2,] <- sound(s)[2,]*seq(1,0,length=sampleLength(s))
play(s)  # right channel fades to zero

## End(Not run)

sound documentation built on May 2, 2019, 2:10 a.m.

Related to sound in sound...