aboutsummaryrefslogtreecommitdiff
path: root/lambeat.scm
diff options
context:
space:
mode:
Diffstat (limited to 'lambeat.scm')
-rw-r--r--lambeat.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/lambeat.scm b/lambeat.scm
new file mode 100644
index 0000000..ac3bb76
--- /dev/null
+++ b/lambeat.scm
@@ -0,0 +1,20 @@
+(use-modules (ice-9 binary-ports))
+(include "music.scm")
+
+(define bitrate 8000)
+
+; Get the music as a list sampled at the bitrate
+(define (play t) (
+ cons (music t) (if (< t 30)
+ (play (+ t (/ 1 bitrate)))
+ '()
+ )
+))
+
+; 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))