sampleLength | R Documentation |
Get or set the length (number of columns in the waveform matrix) of a Sample object or a wav file.
sampleLength(s)
sampleLength(s) <- value
setSampleLength(s,value)
s |
a Sample object, or a string giving the name of a wav file. |
value |
an integer giving the sample length (number of columns in the waveform matrix). |
The replacement form can be used to reset the sample length (here, filenames are not accepted).
If a Sample object is shortened, extra values are discarded. When a Sample object is lengthened, it is padded out to its new length with zeros (silence).
For sampleLength
, the number of columns in the waveform matrix of the sample.
For setSampleLength
, a Sample object with the new length.
Author: Matthias Heymann [aut], Stefan Langenberg [cre] (<https://orcid.org/0000-0001-5817-5469>)
Maintainer: Stefan Langenberg <langenberg@uni-bonn.de>
duration
## Not run:
s <- Sine(440,3,rate=44100,bits=16,channels=2)
sampleLength(s) # 132300 samples ( = 3 sec * 44100 samples/sec )
sampleLength(s) <- 22050 # sample is now .5 sec long
play(setSampleLength(s,44100)) # plays a .5 sec sine wave and then .5 sec silence
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.