ffmpeg support

This commit is contained in:
2026-04-28 15:04:12 +02:00
parent d78a0ae9ff
commit d55f52818d
33 changed files with 157 additions and 22 deletions
+43 -4
View File
@@ -4,10 +4,13 @@
simple-log
"private/utils.rkt"
racket-sprintf
racket/runtime-path
;data/queue
;racket-sound
)
(define-runtime-path tests "tests")
(define test-file3 #f)
(define test-file4 #f)
(define test-file3-id 3)
@@ -15,8 +18,9 @@
(let ((os (system-type 'os)))
(when (eq? os 'unix)
;(set! test-file3 "/muziek/Klassiek-Viool/Alina Ibragimova/Paganini_24 Caprices (2021)/24. 24 Caprices, Op 1 - No. 24 in A minor- Tema con variazioni. Quasi presto.flac")
(set! test-file3 "/tmp/test.mp3")
(set! test-file4 "/tmp/test1.mp3")
;(set! test-file3 "/tmp/test.mp3")
(set! test-file3 (build-path tests "mahler-1.mp3"))
(set! test-file4 (build-path tests "mahler-2.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")
@@ -34,6 +38,10 @@
(define current-file-id -1)
(define current-audio-h #f)
(define current-bits -1)
(define current-rate -1)
(define current-channels -1)
(sl-log-to-display)
(define wav-output-file #f)
(define seeked #f)
@@ -51,12 +59,43 @@
(when (= (round current-seconds) 10)
(when (and (= current-file-id 3) (not seeked))
(set! seeked #t)
(audio-seek current-audio-h 97.0)))))
(let ((perc (exact->inexact (* (/ (- duration 15) duration) 100.0))))
(info-sound "Seeking to ~a%" perc)
(audio-seek current-audio-h perc))))))
)
(when (not (eq? ao-h #f))
(when (not (and
(= current-bits bits-per-sample)
(= current-rate rate)
(= current-channels channels)))
(ao-close ao-h)
(set! ao-h #f)))
;(displayln buf-info)
(when (eq? ao-h #f)
(set! ao-h (ao-open-file bits-per-sample rate channels 'native-endian wav-output-file)))
(info-sound "Opening ao handle")
(info-sound "bits-per-sample: ~a" bits-per-sample)
(info-sound "rate : ~a" rate)
(info-sound "channels : ~a" channels)
(info-sound "endian : ~a" 'native-endian)
(info-sound "(optional) file: ~a" wav-output-file)
(sync-log-sound)
(set! ao-h (ao-open-file bits-per-sample rate channels 'native-endian wav-output-file))
(set! current-bits bits-per-sample)
(set! current-rate rate)
(set! current-channels channels)
(info-sound "ao bits per sample: ~a" (ao-device-bits ao-h))
(sync-log-sound)
)
;(displayln 'ao-play)
;(dbg-sound "Playing audio at ~a" second)
;(sync-log-sound)
(ao-play ao-h current-file-id second duration buffer buf-len ao-type)
(set! duration (inexact->exact (round duration)))
;(displayln 'done)