aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lambeat.scm22
-rw-r--r--lib.scm20
-rw-r--r--music.scm19
3 files changed, 25 insertions, 36 deletions
diff --git a/lambeat.scm b/lambeat.scm
index e98af09..1bcc730 100644
--- a/lambeat.scm
+++ b/lambeat.scm
@@ -5,17 +5,15 @@
(define bitrate 8000)
; Get the music as a list sampled at the bitrate
-(define (play t end) (
- cons (* 1/4 (tri (* t (music t)))) (if (< t end)
- (play (+ t (/ 1 bitrate)) end)
- '()
- )
-))
+(define (play t end)
+ (cons (* 1/4 (tri (* t (music t))))
+ (if (< t end)
+ (play (+ t (/ 1 bitrate)) end)
+ '())))
; Output the list in the s16 raw audio format
-(for-each (lambda (a) (
- let ((b (modulo (inexact->exact (round (* (+ a 2) 32768))) 65536)))
- cons
- (put-u8 (current-output-port) (modulo b 256))
- (put-u8 (current-output-port) (quotient b 256))
-)) (play 0 4))
+(for-each (lambda (a)
+ (let ((b (modulo (inexact->exact (round (* (+ a 2) 32768))) 65536))) cons
+ (put-u8 (current-output-port) (modulo b 256))
+ (put-u8 (current-output-port) (quotient b 256))))
+ (play 0 4))
diff --git a/lib.scm b/lib.scm
index 5a12152..6ce6cf8 100644
--- a/lib.scm
+++ b/lib.scm
@@ -1,21 +1,17 @@
; Triangle wave with a period of 1 second
-(define (tri t) (
- let ((m (floor-remainder (+ t (/ 1 4)) 1)))
+(define (tri t)
+ (let ((m (floor-remainder (+ t (/ 1 4)) 1)))
(if (< m 1/2)
(- (* 4 m) 1)
- (- 3 (* 4 m)))
-))
+ (- 3 (* 4 m)))))
; Creates a note
-(define (note freq start len) (
- lambda (t) (
+(define (note freq start len)
+ (lambda (t) (
if (or (< t start) (>= t (+ start len)))
0
- freq
- )
-))
+ freq)))
; Gets the frequency of a particular pitch
-(define (getfreq octave pitch) (
- * 55 (ash 1 octave) (expt 2 (/ pitch 13))
-))
+(define (getfreq octave pitch)
+ (* 55 (ash 1 octave) (expt 2 (/ pitch 13))))
diff --git a/music.scm b/music.scm
index 7934bda..f994c6d 100644
--- a/music.scm
+++ b/music.scm
@@ -1,10 +1,9 @@
(include "lib.scm")
-(define (melody t) (
- apply + (
- map (lambda (x) (
- apply (lambda (octave pitch start len) ((note (getfreq octave pitch) start len) t)) x
- )) '(
+(define (melody t)
+ (apply + (map (lambda (x)
+ (apply (lambda (octave pitch start len) ((note (getfreq octave pitch) start len) t)) x))
+ '(
(2 5 1 1)
(2 8 4 1)
(3 5 7 1)
@@ -20,11 +19,7 @@
(3 3 23 1)
(3 5 25 1)
(3 0 30 1)
- (3 3 31 1)
- )
- )
-))
+ (3 3 31 1)))))
-(define (music t) (
- melody (* t 8)
-))
+(define (music t)
+ (melody (* t 8)))