mp3 support, based on mpg123
This commit is contained in:
+16
-10
@@ -3,6 +3,7 @@
|
||||
"audio-decoder.rkt"
|
||||
simple-log
|
||||
"private/utils.rkt"
|
||||
racket-sprintf
|
||||
;data/queue
|
||||
;racket-sound
|
||||
)
|
||||
@@ -11,7 +12,9 @@
|
||||
(define test-file3-id 3)
|
||||
(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 "/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")
|
||||
)
|
||||
(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-Viool\\Janine Jansen\\Janine Jansen - Sibelius en Prokovief 1 (2024)\\02 - Violin Concerto in D Minor, Op. 47 II. Adagio di molto.flac")
|
||||
@@ -26,7 +29,7 @@
|
||||
|
||||
(sl-log-to-display)
|
||||
|
||||
(define (audio-play type handle buf-info buffer buf-len)
|
||||
(define (audio-play type ao-type handle buf-info buffer buf-len)
|
||||
(let* ((sample (hash-ref buf-info 'sample))
|
||||
(rate (hash-ref buf-info 'sample-rate))
|
||||
(second (/ (* sample 1.0) (* rate 1.0)))
|
||||
@@ -36,11 +39,12 @@
|
||||
(bytes-per-sample-all-channels (* channels bytes-per-sample))
|
||||
(duration (hash-ref buf-info 'duration))
|
||||
)
|
||||
(displayln buf-info)
|
||||
;(displayln buf-info)
|
||||
(when (eq? ao-h #f)
|
||||
(set! ao-h (ao-open-live bits-per-sample rate channels 'big-endian)))
|
||||
(set! ao-h (ao-open-live bits-per-sample rate channels 'native-endian)))
|
||||
;(displayln 'ao-play)
|
||||
(ao-play ao-h test-file3-id second duration buffer buf-len type)
|
||||
(ao-play ao-h test-file3-id second duration buffer buf-len ao-type)
|
||||
(set! duration (inexact->exact (round duration)))
|
||||
;(displayln 'done)
|
||||
(let ((second-printer (λ (buf-seconds)
|
||||
(let ((s (inexact->exact (round (ao-at-second ao-h)))))
|
||||
@@ -52,7 +56,8 @@
|
||||
(tseconds (remainder duration 60))
|
||||
(volume (ao-volume ao-h))
|
||||
)
|
||||
(displayln (format "At time: ~a:~a (~a:~a) - ~a - volume: ~a"
|
||||
(info-sound
|
||||
(sprintf "At time: %02d:%02d (%02d:%02d) - %d - volume: %d"
|
||||
minutes seconds
|
||||
tminutes tseconds
|
||||
buf-seconds
|
||||
@@ -68,7 +73,7 @@
|
||||
bytes-per-sample-all-channels
|
||||
rate))))
|
||||
(if (< buf-seconds-left 2.0)
|
||||
(displayln (format "Seconds in buffer left: ~a" buf-seconds-left))
|
||||
(info-sound "Seconds in buffer left: ~a" buf-seconds-left)
|
||||
(begin
|
||||
(sleep 0.5)
|
||||
(second-printer buf-seconds)
|
||||
@@ -89,9 +94,10 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define (audio-meta type handle meta)
|
||||
(dbg-sound "type: ~a" type)
|
||||
(dbg-sound "meta: ~a" meta))
|
||||
(define (audio-meta type ao-type handle meta)
|
||||
(dbg-sound "type: ~a" type)
|
||||
(dbg-sound "ao-type: ~a" ao-type)
|
||||
(dbg-sound "meta: ~a" meta))
|
||||
|
||||
(define (play)
|
||||
(set! ao-h #f)
|
||||
|
||||
Reference in New Issue
Block a user