small cleanup
parent
5340fc7bae
commit
54633487c5
24
src/flac.scm
24
src/flac.scm
|
@ -47,7 +47,8 @@
|
|||
(let ((old-output (current-output-port)))
|
||||
(with-input-from-file infile
|
||||
(λ ()
|
||||
(with-flac-input-port (current-input-port)
|
||||
(with-flac-input-port
|
||||
(current-input-port)
|
||||
(λ ()
|
||||
(let* ((stream-info (flac-metadata-stream-info (read-flac-metadata)))
|
||||
(sample-data-length (* (stream-info-samples stream-info)
|
||||
|
@ -75,8 +76,6 @@
|
|||
(data-chunk-size ,(* (stream-info-samples stream-info)
|
||||
(stream-info-channels stream-info)
|
||||
(floor-quotient (stream-info-bits-per-sample stream-info) 8)))))))
|
||||
(format #t "SAMPLES: ~a\n" (stream-info-samples stream-info))
|
||||
(format #t "bps: ~a\n" (stream-info-bits-per-sample stream-info))
|
||||
(with-output-to-file outfile
|
||||
(lambda ()
|
||||
(put-bytevector (current-output-port) (bytestructure-unwrap wav-header))
|
||||
|
@ -87,21 +86,4 @@
|
|||
(begin
|
||||
(write-frame frame (stream-info-channels stream-info))
|
||||
(frame-loop (+ 1 frame-number)
|
||||
(read-flac-frame stream-info))))))
|
||||
#:binary #t))))))))
|
||||
;
|
||||
; (format #t "SAMPLES: ~a\n" (stream-info-samples stream-info))
|
||||
; (format #t "bps: ~a\n" (stream-info-bits-per-sample stream-info))
|
||||
; (with-output-to-file outfile
|
||||
; (lambda ()
|
||||
; (put-bytevector (current-output-port) (bytestructure-unwrap wav-header))
|
||||
; (let frame-loop ((frame-number 0)
|
||||
; (frame (read-flac-frame stream-info)))
|
||||
; (if (= (stream-info-samples stream-info) frame-number)
|
||||
; #t
|
||||
; (begin
|
||||
; (format old-output "frame ~a\n" frame)
|
||||
; (write-frame frame (stream-info-channels stream-info))
|
||||
; (frame-loop (+ 1 frame-number)
|
||||
; (read-flac-frame stream-info))))))))))))
|
||||
; #:binary #t))))))))
|
||||
(read-flac-frame stream-info))))))))))))))
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
(read-metadata-block metadata block-length block-type)
|
||||
(metadata-loop (read-metadata-block metadata block-length block-type))))))
|
||||
|
||||
; FIXME: bail early if not in type
|
||||
;;; FIXME: bail early if not in type
|
||||
(define (read-flac-metadata-type type)
|
||||
(let metadata-loop ()
|
||||
(receive (last-block? block-type block-length)
|
||||
|
@ -103,14 +103,16 @@
|
|||
(metadata-loop))))))
|
||||
|
||||
(define* (flac-metadata port #:optional (type #f))
|
||||
(with-flac-input-port port
|
||||
(with-flac-input-port
|
||||
port
|
||||
(λ ()
|
||||
(if (symbol? type)
|
||||
(read-flac-metadata-type type)
|
||||
(read-flac-metadata)))))
|
||||
|
||||
(define* (flac-file-metadata filename #:optional (type #f))
|
||||
(with-flac-input-port (open-input-file filename #:binary #t)
|
||||
(with-flac-input-port
|
||||
(open-input-file filename #:binary #t)
|
||||
(λ ()
|
||||
(flac-read/assert-magic)
|
||||
(flac-metadata (current-input-port) type))))
|
||||
|
|
Loading…
Reference in New Issue