Added volume controle on sample level.

libao-async will adjust the volume of the samples.
This commit is contained in:
2026-04-21 10:10:29 +02:00
parent 8182b17096
commit a7caad7fa4
4 changed files with 39 additions and 5 deletions

View File

@@ -48,16 +48,18 @@
(seconds (remainder s 60))
(tminutes (quotient duration 60))
(tseconds (remainder duration 60))
(volume (ao-volume ao-h))
)
(displayln (format "At time: ~a:~a (~a:~a) - ~a"
(displayln (format "At time: ~a:~a (~a:~a) - ~a - volume: ~a"
minutes seconds
tminutes tseconds
buf-seconds
volume
))))))))
(let* ((buf-size (ao-bufsize-async ao-h))
(buf-seconds (exact->inexact (/ buf-size bytes-per-sample-all-channels rate))))
(second-printer buf-seconds)
(when (> buf-seconds 30)
(when (> buf-seconds 10)
(letrec ((waiter (λ ()
(let ((buf-seconds-left (exact->inexact
(/ (ao-bufsize-async ao-h)
@@ -66,8 +68,18 @@
(if (< buf-seconds-left 2.0)
(displayln (format "Seconds in buffer left: ~a" buf-seconds-left))
(begin
(sleep 1)
(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))
(waiter)))))
))
(waiter))))