aboutsummaryrefslogtreecommitdiff
path: root/lib.scm
diff options
context:
space:
mode:
authorAnthony Wang2022-12-17 18:37:07 -0600
committerAnthony Wang2022-12-17 18:37:07 -0600
commit3da3a7f6c5ee83373ef4e6e3232cc5a371137e68 (patch)
tree454427a3f00f9e34e06362f03b3441b825989b19 /lib.scm
parentf11992a8fca36b7be77c7225a0007468bf6a29cb (diff)
Split into multiple files and rewrite README
Diffstat (limited to 'lib.scm')
-rw-r--r--lib.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib.scm b/lib.scm
new file mode 100644
index 0000000..66d2a0e
--- /dev/null
+++ b/lib.scm
@@ -0,0 +1,18 @@
+(define (saw t) (
+ let ((m (floor-remainder (+ t (/ 1 4)) 1)))
+ (if (< m 1/2)
+ (- (* 4 m) 1)
+ (- 3 (* 4 m)))
+))
+
+(define (note freq start len) (
+ lambda (t) (
+ if (or (< t start) (>= t (+ start len)))
+ 0
+ (saw (* freq t))
+ )
+))
+
+(define (getfreq octave pitch) (
+ * 55 (ash 1 octave) (expt 2 (/ pitch 13))
+))