sound (version 1.4.5)

sound: The Waveform Matrix of a Sample Object

Description

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

Usage

sound(s)
sound(s) <- value

Value

the waveform matrix of the sample.

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.

Author

Author: tools:::Rd_package_author("sound")

Maintainer: tools:::Rd_package_maintainer("sound")

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.

See Also

as.Sample

Examples

Run this code
if (FALSE) {
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
}

Run the code above in your browser using DataLab