racket version of async C backend

This commit is contained in:
2026-05-03 10:13:28 +02:00
parent 856c790257
commit 92227133ff
5 changed files with 1090 additions and 30 deletions
+17 -13
View File
@@ -21,8 +21,8 @@
(set! test-file4 (build-path tests "mahler-2.ogg"))
)
(when (eq? os 'windows)
(set! test-file3 (build-path tests "mahler-1.ogg"))
(set! test-file4 (build-path tests "mahler-2.ogg"))
(set! test-file3 (build-path tests "idyll.flac"))
(set! test-file4 (build-path tests "idyll.flac"))
)
)
@@ -43,6 +43,7 @@
(define seeked #f)
(define (audio-play type ao-type handle buf-info buffer buf-len)
;(dbg-sound "~a ~a ~a ~a ~a" type ao-type handle buf-info buf-len)
(let* ((sample (hash-ref buf-info 'sample))
(rate (hash-ref buf-info 'sample-rate))
(second (/ (* sample 1.0) (* rate 1.0)))
@@ -58,8 +59,19 @@
(let ((perc (exact->inexact (* (/ (- duration 15) duration) 100.0))))
(info-sound "Seeking to ~a%" perc)
(audio-seek current-audio-h perc))))))
(cond-volume (λ ()
(when (= (round current-seconds) 20)
(ao-set-volume! ao-h 70.0))
(when (= (round current-seconds) 25)
(ao-set-volume! ao-h 30))
(when (= (round current-seconds) 30)
(ao-set-volume! ao-h 100))
(when (= (round current-seconds) 35)
(ao-set-volume! ao-h 150))
(when (= (round current-seconds) 40)
(ao-set-volume! ao-h 100))))
)
(when (not (eq? ao-h #f))
(when (not (and
(= current-bits bits-per-sample)
@@ -116,6 +128,7 @@
(buf-seconds (exact->inexact (/ buf-size bytes-per-sample-all-channels rate))))
(second-printer buf-seconds)
(cond-seek)
(cond-volume)
(when (> buf-seconds 5)
(letrec ((waiter (λ ()
(let ((buf-seconds-left (exact->inexact
@@ -127,16 +140,7 @@
(begin
(sleep 0.5)
(second-printer buf-seconds)
(when (= (round current-seconds) 20)
(ao-set-volume! ao-h 70.0))
(when (= (round current-seconds) 25)
(ao-set-volume! ao-h 30))
(when (= (round current-seconds) 30)
(ao-set-volume! ao-h 100))
(when (= (round current-seconds) 35)
(ao-set-volume! ao-h 150))
(when (= (round current-seconds) 40)
(ao-set-volume! ao-h 100))
(cond-volume)
(cond-seek)
(waiter)))))
))