sound (version 1.4.5)

rate: The Sampling Rate

Description

Get or set the sampling rate (number of samples per second) of a Sample object or a wav file.

Usage

rate(s)
rate(s) <- value
setRate(s,value)

Value

For rate, the sampling rate (number of samples per second) of the sample.

For setRate, a Sample object with the new sampling rate.

Arguments

s

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

value

an integer between 1000 and 192000 giving the sampling rate.

Author

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

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

Details

The replacement form can be used to reset the sampling rate. Here, filenames are not accepted.

Note that changing the sampling rate of a Sample object affects the waveform of the sample.

See Also

fitSampleParameters, pitch

Examples

Run this code
if (FALSE) {
s <- Sine(440,1,rate=44100)
rate(s)  # 44100
play(s)
print(s)
rate(s) <- 8000
play(s)  # s has worse quality now (noise and additional high frequencies)
print(s) # but uses less memory
}

Run the code above in your browser using DataLab