sampleLength {sound} | R Documentation |
Length of a Sample Object
Description
Get or set the length (number of columns in the waveform matrix) of a Sample object or a wav file.
Usage
sampleLength(s)
sampleLength(s) <- value
setSampleLength(s,value)
Arguments
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). |
Details
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).
Value
For sampleLength
, the number of columns in the waveform matrix of the sample.
For setSampleLength
, a Sample object with the new length.
Author(s)
Author: Matthias Heymann [aut], Stefan Langenberg [cre] (<https://orcid.org/0000-0001-5817-5469>)
Maintainer: Stefan Langenberg <langenberg@uni-bonn.de>
See Also
Examples
## 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)