rate: The Sampling Rate

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

View source: R/sound.R

Description

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

Usage

1
2
3
rate(s)
rate(s) <- value
setRate(s,value)

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.

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.

Value

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

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

Note

Common sampling rates are between 8000 and 44100 (CD quality). Higher-quality recorders typically work with sampling rates of 48000, 92000 or 192000. Not every rate is guaranteed to be supported by every wav file player.

Future versions may use a different algorithm for sampling rate conversion to achieve a better sound quality for the returned sample.

Author(s)

Author: Matthias Heymann <[email protected]>

Maintainer: Stefan Langenberg <[email protected]>

See Also

fitSampleParameters, pitch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
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

## End(Not run)

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