# this is a simple variation on the equal_terperament_test program.
# don't worry about how the sounds are created in this example,
# rather observe the way the equal tempered fifth beats while
# the perfect ones do not.
library(tuneR) # need to like with the sound library
f = 400 # our base frequency
sr = 16000 # sampling rate
bits = 16 # bit depth
secs = 3. # length of each note
c = 3/2 # a 3:2 perfect fifth
#c = 2^(7/12) # an equal temp perfect fifth
t = seq(0,secs,1/sr) # the time points we create samples for
y = rep(0,length(t));
for (i in 1:3) y = y+ sin(2*pi*i*f*t);
f = f*c; # move frequency up by interval described by c
x = rep(0,length(t))
for (i in 1:3) x = x+ sin(2*pi*i*f*t);
z = c(y,x,y+x); # first y, then x, then both
u = Wave(2^(bits-5)*z, samp.rate = sr, bit=16) # make wave struct
play(u) # play it