sound (version 1.4.5)

center: Center a Sample Object.

Description

This function adds a constant to a Sample object's waveform, so that its mean gets zero. This makes sense especially for sonification purposes, when (in general non-centered) data is transformed into sound.

Usage

center(s)

Value

a Sample object with zero as the mean of each channel's waveform.

Arguments

s

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

Author

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

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

Details

For a stereo Sample object, both channels are treated separately.

See Also

normalize

Examples

Run this code
if (FALSE) {
x <- seq(0,50*pi,length=10000)
waveform <- (sin(x))^2 + .6*cos(x/2)^2
s <- as.Sample(waveform,44100,16)
plot(s) # nice idea, but wrong range for a sample
play(s) # sounds ugly, too
s <- center(s)
plot(s)  # now zero is the mean
play(s)  # sounds good, but too quiet
s <- normalize(s)
plot(s)  # this looks like a perfect sample!
play(s)  # e voila!
}

Run the code above in your browser using DataCamp Workspace