duration {sound}R Documentation

Duration of a Sample Object

Description

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

Usage

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 [aut], Stefan Langenberg [cre] (<https://orcid.org/0000-0001-5817-5469>)

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

See Also

sampleLength

Examples

## 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)

[Package sound version 1.4.6 Index]