sampleLength: Length of a Sample Object

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

View source: R/sound.R

Description

Get or set the length (number of columns in the waveform matrix) of a Sample object or a wav file.

Usage

1
2
3
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 <mail@MatthiasHeymann.de>

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

See Also

duration

Examples

1
2
3
4
5
6
7
## 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)

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

Related to sampleLength in sound...