sound (version 1.4.5)

duration: 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)

Value

For duration, the duration of the sample in seconds.

For setDuration, a Sample object with the new duration.

Arguments

s

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

value

a double giving the duration in seconds.

Author

Author: tools:::Rd_package_author("sound")

Maintainer: tools:::Rd_package_maintainer("sound")

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

See Also

sampleLength

Examples

Run this code
if (FALSE) {
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
}

Run the code above in your browser using DataCamp Workspace