sound | R Documentation |
Get or set the waveform matrix of a Sample object or a wav file.
sound(s)
sound(s) <- value
s |
a Sample object, or a string giving the name of a wav file. |
value |
a |
The replacement form can be used to reset the waveform of a sample object. Here, filenames are not accepted for s
.
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.
the waveform matrix of the sample.
Author: Matthias Heymann [aut], Stefan Langenberg [cre] (<https://orcid.org/0000-0001-5817-5469>)
Maintainer: Stefan Langenberg <langenberg@uni-bonn.de>
as.Sample
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.