aboutsummaryrefslogtreecommitdiff
path: root/lib.scm
blob: 6c8652193c10d998b03ffdda03d46466f503c341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; Saw wave with a period of 1 second
(define (saw t) (
	let ((m (floor-remainder (+ t (/ 1 4)) 1)))
		(if (< m 1/2)
			(- (* 4 m) 1)
			(- 3 (* 4 m)))
))

; Creates a note
(define (note freq start len) (
	lambda (t) (
		if (or (< t start) (>= t (+ start len)))
			0
			(saw (* freq t))
	)
))

; Gets the frequency of a particular pitch
(define (getfreq octave pitch) (
	* 55 (ash 1 octave) (expt 2 (/ pitch 13))
))