xiph opusfile support and taglib write support.

This commit is contained in:
2026-06-07 23:49:38 +02:00
parent cf87fa7ed8
commit 4b6adc404e
8 changed files with 905 additions and 303 deletions
+25 -9
View File
@@ -24,9 +24,21 @@
;; Opus decode output is always 48 kHz PCM. The original input rate, if
;; present in metadata, is not the actual decoder output rate.
(define libopusfile
(with-handlers ([exn:fail? (lambda (_) #f)])
(ffi-lib "libopusfile" '("0" #f))))
(define libogg (get-lib (case (system-type 'os)
[(windows) '("ogg")]
[else '("ogg" "libogg")])
'(#f)))
(define libopus (get-lib (case (system-type 'os)
[(windows) '("opus")]
[else '("opus" "libopus")])
'(#f)))
(define libopusfile (get-lib (case (system-type 'os)
[(windows) '("opusfile")]
[else '("opusfile" "libopusfile")])
'(#f)))
(define _OggOpusFile _pointer)
@@ -36,12 +48,16 @@
(define (opusfile-output-format? v)
(or (eq? v 's16) (eq? v 's24)))
(define current-opusfile-output-format
(make-parameter 's16
(lambda (v)
(unless (opusfile-output-format? v)
(raise-argument-error 'current-opusfile-output-format "(or/c 's16 's24)" v))
v)))
(define cur-output-format 's16)
(define (current-opusfile-output-format . args)
(unless (null? args)
(if (or (> (length args) 1)
(not (opusfile-output-format? (car args))))
(raise-argument-error 'current-opusfile-output-format
"(or/c 's16 's24)")
(set! cur-output-format (car args))))
cur-output-format)
(define (opus-bits-per-sample)
(case (current-opusfile-output-format)