This commit is contained in:
2026-02-22 23:15:08 +01:00
parent 2cc96f30ae
commit 24b39bee60
8 changed files with 101 additions and 32 deletions

View File

@@ -16,14 +16,36 @@
(let* ((sample (hash-ref frame 'number))
(rate (hash-ref frame 'sample-rate))
(second (/ (* sample 1.0) (* rate 1.0)))
(bits-per-sample (hash-ref frame 'bits-per-sample))
(bytes-per-sample (/ bits-per-sample 8))
(channels (hash-ref frame 'channels))
(bytes-per-sample-all-channels (* channels bytes-per-sample))
)
(ao-play ao-h second buffer)
(let ((second-printer (λ ()
(let ((s (inexact->exact (round (ao-at-second ao-h)))))
(when (> s current-seconds)
(set! current-seconds s)
(displayln (format "At second: ~a" s)))))))
(let* ((buf-size (ao-bufsize-async ao-h))
(buf-seconds (exact->inexact (/ buf-size bytes-per-sample-all-channels rate))))
(second-printer)
(when (> buf-seconds 5)
(letrec ((waiter (λ ()
(let ((buf-seconds-left (exact->inexact
(/ (ao-bufsize-async ao-h)
bytes-per-sample-all-channels
rate))))
(if (< buf-seconds-left 2.0)
(displayln (format "Seconds in buffer left: ~a" buf-seconds-left))
(begin
(sleep 0.5)
(second-printer)
(waiter)))))
))
(waiter))))
)
)
(let ((s (inexact->exact (round (ao-at-second ao-h)))))
(when (> s current-seconds)
(set! current-seconds s)
(displayln (format "At second: ~a" (ao-at-second ao-h)))
))
)
(define (flac-meta meta)