aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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