trying to overcome gapless problems with mpg123 (very small tick left) and facilitate output to wav

This commit is contained in:
2026-04-23 11:03:47 +02:00
parent 4bbfa43501
commit 3fd5fdbdd5
5 changed files with 120 additions and 77 deletions
+11 -4
View File
@@ -19,8 +19,10 @@
(set! test-file4 "/tmp/test1.mp3")
)
(when (eq? os 'windows)
(set! test-file3 "C:\\Muziek\\Klassiek-Strijkkwartet\\Quatuor Zaïde\\Franz\\01 Erlkönig, D. 328 (Arr. For String Quartet by Eric Mouret).flac")
;(set! test-file3 "C:\\Muziek\\Klassiek-Strijkkwartet\\Quatuor Zaïde\\Franz\\01 Erlkönig, D. 328 (Arr. For String Quartet by Eric Mouret).flac")
;(set! test-file3 "C:\\Muziek\\Klassiek-Viool\\Janine Jansen\\Janine Jansen - Sibelius en Prokovief 1 (2024)\\02 - Violin Concerto in D Minor, Op. 47 II. Adagio di molto.flac")
(set! test-file3 "c:\\tmp\\test.mp3")
(set! test-file4 "c:\\tmp\\test1.mp3")
)
)
@@ -33,6 +35,7 @@
(define current-audio-h #f)
(sl-log-to-display)
(define wav-output-file #f)
(define (audio-play type ao-type handle buf-info buffer buf-len)
(let* ((sample (hash-ref buf-info 'sample))
@@ -46,7 +49,7 @@
)
;(displayln buf-info)
(when (eq? ao-h #f)
(set! ao-h (ao-open-live bits-per-sample rate channels 'native-endian)))
(set! ao-h (ao-open-file bits-per-sample rate channels 'native-endian wav-output-file)))
;(displayln 'ao-play)
(ao-play ao-h current-file-id second duration buffer buf-len ao-type)
(set! duration (inexact->exact (round duration)))
@@ -71,13 +74,16 @@
(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 10)
(when (= (round current-seconds) 10)
(when (= current-file-id 3)
(audio-seek current-audio-h 97.0)))
(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)
(if (< buf-seconds-left 3.0)
(info-sound "Seconds in buffer left: ~a" buf-seconds-left)
(begin
(sleep 0.5)
@@ -114,6 +120,7 @@
(set! current-audio-h audio-h)
(audio-read audio-h)
)
(info-sound "Opening next file: ~a" test-file4)
(let ((audio-h (audio-open test-file4 audio-meta audio-play)))
(set! current-file-id test-file4-id)
(set! current-audio-h audio-h)