Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Created June 11, 2012 03:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ircmaxell/2908355 to your computer and use it in GitHub Desktop.
Save ircmaxell/2908355 to your computer and use it in GitHub Desktop.
Sanity Test - Try to listen for more than 1 hour without going crazy
import random, time, winsound
timebias = 0.2
pitchbias = 0.7
changebias = 0.75
current = [(4.,1.),(5.,1.),(7.,3.),(None,1.), (4.,1.),(5.,1.),(7.,3.),(None,1.),(4.,1.),(7.,1.),(12.,2.),(11.,2.),(9.,2.),(9.,2.),(7.,1.),(None,1.),(2.,1.),(4.,1.),(5.,3.),(None,1.),(2.,1.),(4.,1.),(5.,3.),(None,1.),(2.,1.),(5.,1.),(11.,1.),(9.,1.),(7.,2.),(11.,2.),(12.,4.)]
timeshift = 1;
while 1:
timeshift = timeshift + timeshift * random.uniform(1 - timebias, 1 + timebias)
if timeshift > 1.0 + 2.0 * timebias or timeshift < 1.0 - 2.0 * timebias:
timeshift = random.uniform(1.0 - timebias / 2.0, 1.0 + timebias / 2.0)
key = random.randrange(0, len(current) - 1)
if random.random() > changebias:
if current[key][0] is not None:
current[key] = (current[key][0] + current[key][0] * random.uniform(-1.0 * pitchbias, pitchbias), current[key][1])
else:
current[key] = (current[key][0], current[key][1] + current[key][1] * random.uniform( -1.0 * timebias, timebias))
time.sleep(random.random())
for (p,d) in current:
if p is None: time.sleep(0.2*d * timeshift)
else: winsound.Beep(int(440*2**(p/12.)), int(200*d*timeshift))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment