37 lines
951 B
Racket
37 lines
951 B
Racket
#lang racket/base
|
|
(require "libao/libao.rkt"
|
|
"libflac/flac-decoder.rkt"
|
|
data/queue
|
|
)
|
|
|
|
|
|
|
|
(define 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")
|
|
(define fmt (ao-mk-format 24 48000 2 'big-endian))
|
|
(define ao-h (ao-open-live #f fmt))
|
|
|
|
(define current-seconds 0)
|
|
|
|
(define (flac-play frame buffer)
|
|
(let* ((sample (hash-ref frame 'number))
|
|
(rate (hash-ref frame 'sample-rate))
|
|
(second (/ (* sample 1.0) (* rate 1.0)))
|
|
)
|
|
(ao-play ao-h second buffer)
|
|
)
|
|
(let ((s (inexact->exact (round (ao-at-second ao-h)))))
|
|
(when (> s current-seconds)
|
|
(set! current-seconds s)
|
|
(displayln (format "At second: ~a" (ao-at-second ao-h)))
|
|
))
|
|
)
|
|
|
|
(define (flac-meta meta)
|
|
(displayln meta))
|
|
|
|
(define flac-h
|
|
(flac-open test-file3 flac-meta flac-play))
|
|
|
|
(flac-read flac-h)
|
|
|