center: Center a Sample Object.

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

View source: R/sound.R

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

1
center(s)

Arguments

s

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

Details

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

Value

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

Author(s)

Author: Matthias Heymann <mail@MatthiasHeymann.de>

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

See Also

normalize

Examples

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

## End(Not run)

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

Related to center in sound...