Syllabus 20091006 Selena
nested loop rhythm
from os import system
freq=open("freq.txt")
i=0
for f in freq:
ff=f.strip()
dur=str(0.5/int(ff))
system("sox -n "+str(i)+".raw synth "+dur+" brown vol 0.7")
system("sox -n "+str(i)+"s.raw synth "+dur+" brown vol 0.0")
for k in range(4):
system("cat "+str(i)+".raw >> loop.raw")
system("cat "+str(i)+"s.raw >> loop.raw")
for m in range(4):
system("cat "+str(i)+".raw >> loop.raw")
system("cat "+str(i)+"s.raw >> loop.raw")
system("cat "+str(i)+"s.raw >> loop.raw")
i=i+1
print i
system("sox --rate 8000 -b 8 -c1 --encoding signed-integer loop.raw loop.wav")
system("rm loop.raw")
system("play loop.wav")
a melody
from os import system
freq = open("freq.txt")
i=0
for f in freq:
#print f.strip()
ff=f.strip()
dur=str(20.0/int(ff))
#print dur
system("sox -n "+str(i)+".raw synth "+dur+" sine "+ff+" vol 0.7")
system("sox -r 8000 -b 8 -c 1 --encoding signed-integer "+str(i)+".raw "+str(i)+".wav")
system("play "+str(i)+".wav")
system("cat "+str(i)+".raw >> song.raw")
i=i+1
freq.txt
220
440
448
410
210
218
238
256
320
390
440
440
440
440
430
380
330
315
316
324
230
224
222
220
220
220
218
216
220
220
220
220