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 DataLab