18 lines
504 B
Scheme
18 lines
504 B
Scheme
(use-modules (ice-9 binary-ports))
|
|
(include "music.scm")
|
|
|
|
; Bitrate is the number time to sample the music function each second
|
|
(define bitrate 8000)
|
|
|
|
; Get the music as a list sampled at the bitrate
|
|
(define (play t end)
|
|
(cons ((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)))) (music t))
|
|
(if (< t end)
|
|
(play (+ t (/ 1 bitrate)) end)
|
|
'())))
|
|
|
|
(play 6 100)
|