blob: 1bcc73008cdaf31057d5341582d4882b77a334f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
(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 (* 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))
|