# create a random walk function where each function value is the previous # one plus a random change. Use this as the time changing frequency # and make a sine wave with this frequency by numerical integration. # sounds like the wind! library(tuneR) # need to like with the sound library sr = 8000 # sampling rate bits = 16 # bit depth secs = 10 t = seq(0,secs,1/sr) f0 = 440 w = 1 f = rep(0,length(t)) f[1] = f0 for (i in 2:length(t)) f[i] = f[i-1] + runif(1,min=-w,max=w) #for (i in 2:length(t)) f[i] = f0 + .995*(f[i-1]-f0) + runif(1,min=-w,max=w) plot(f,type='l') y = sin(cumsum(2*pi*f/sr)) u = Wave(round(2^(bits-4)*y), samp.rate = sr, bit=16) # make wave struct play(u,"play") # play it