duration: Duration of a Sample Object

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

View source: R/sound.R

Description

Get or set the duration (in seconds) of a Sample object or a wav file.

Usage

1
2
3
duration(s)
duration(s) <- value
setDuration(s,value)

Arguments

s

a Sample object, or a string giving the name of a wav file.

value

a double giving the duration in seconds.

Details

The replacement form can be used to reset the duration of the Sample object (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 duration, the duration of the sample in seconds.

For setDuration, a Sample object with the new duration.

Author(s)

Author: Matthias Heymann <mail@MatthiasHeymann.de>

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

See Also

sampleLength

Examples

1
2
3
4
5
6
7
## Not run: 
s <- Sine(440,3)
duration(s)  # 3
duration(s) <-.5  # sample is now .5 sec long
play(setDuration(s,1)) # 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 duration in sound...