aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Cholewiński <harry666t@gmail.com>2016-10-17 11:36:36 +0200
committerKamil Cholewiński <harry666t@gmail.com>2016-10-17 11:36:36 +0200
commitc6070665bd973d478547058f92fd2205e768da5a (patch)
tree33d6e3dd803f04e4d3437840f795af9a39277135
parent9b69e0ec2dcfe37a5d83b74afc2995085f7e3718 (diff)
downloadeighth-master.zip
eighth-master.tar.gz
eighth-master.tar.bz2
add sounds.pyHEADmaster
-rw-r--r--sounds.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/sounds.py b/sounds.py
new file mode 100644
index 0000000..c47d485
--- /dev/null
+++ b/sounds.py
@@ -0,0 +1,23 @@
+import sys
+import math
+
+
+if sys.version_info < (3,):
+ def six_bytes(it):
+ return "".join(chr(x) for x in it)
+else:
+ six_bytes = bytes
+
+
+def mkstep(f, t, bufsz):
+ return six_bytes((f(t+i) % 255 for i in range(bufsz)))
+
+
+def step(t):
+ return mkstep(mksound, t, 0xffff)
+
+
+def mksound(t):
+ t = t & 0xffffff
+ x = (t & 0xff) ** 2
+ return (x ^ (t * 3)) & (t>>3) & x