working decoder?
parent
3b96fbc28d
commit
008d217286
19
src/flac.scm
19
src/flac.scm
|
@ -44,6 +44,7 @@
|
||||||
(iota (frame-header-blocksize header)))))
|
(iota (frame-header-blocksize header)))))
|
||||||
|
|
||||||
(define (decode-flac-file infile outfile)
|
(define (decode-flac-file infile outfile)
|
||||||
|
(let ((old-output (current-output-port)))
|
||||||
(with-input-from-file infile
|
(with-input-from-file infile
|
||||||
(λ ()
|
(λ ()
|
||||||
(with-flac-input-port (current-input-port)
|
(with-flac-input-port (current-input-port)
|
||||||
|
@ -87,4 +88,20 @@
|
||||||
(write-frame frame (stream-info-channels stream-info))
|
(write-frame frame (stream-info-channels stream-info))
|
||||||
(frame-loop (+ 1 frame-number)
|
(frame-loop (+ 1 frame-number)
|
||||||
(read-flac-frame stream-info))))))
|
(read-flac-frame stream-info))))))
|
||||||
#:binary #t)))))))
|
#: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))))))))
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
(parameters '())
|
(parameters '())
|
||||||
(raw-bits '())
|
(raw-bits '())
|
||||||
(residual '()))
|
(residual '()))
|
||||||
(if (= partition partitions)
|
(if (>= partition partitions)
|
||||||
(values (%make-entropy-coding-method
|
(values (%make-entropy-coding-method
|
||||||
coding-method
|
coding-method
|
||||||
(%make-rice-partition
|
(%make-rice-partition
|
||||||
|
|
|
@ -120,7 +120,6 @@
|
||||||
(header subframe-header)
|
(header subframe-header)
|
||||||
(data subframe-data))
|
(data subframe-data))
|
||||||
|
|
||||||
|
|
||||||
(define-record-type <subframe-lpc>
|
(define-record-type <subframe-lpc>
|
||||||
(%make-subframe-lpc entropy-coding-method order qlp-coefficient-precision quantization-level qlp-coefficients warmup residual)
|
(%make-subframe-lpc entropy-coding-method order qlp-coefficient-precision quantization-level qlp-coefficients warmup residual)
|
||||||
subframe-lpc?
|
subframe-lpc?
|
||||||
|
@ -169,7 +168,6 @@
|
||||||
(type entropy-coding-method-type)
|
(type entropy-coding-method-type)
|
||||||
(data entropy-coding-method-data))
|
(data entropy-coding-method-data))
|
||||||
|
|
||||||
|
|
||||||
(define-record-type <frame-header>
|
(define-record-type <frame-header>
|
||||||
(make-frame-header blocking-strategy blocksize sample-rate channel-assignment bits-per-sample frame/sample-number crc)
|
(make-frame-header blocking-strategy blocksize sample-rate channel-assignment bits-per-sample frame/sample-number crc)
|
||||||
frame-header?
|
frame-header?
|
||||||
|
@ -332,6 +330,11 @@
|
||||||
(λ (record port)
|
(λ (record port)
|
||||||
(format port "#<<picture> type: ~a mime-type: ~a>" (picture-type record) (picture-mime-type record))))
|
(format port "#<<picture> type: ~a mime-type: ~a>" (picture-type record) (picture-mime-type record))))
|
||||||
|
|
||||||
|
(set-record-type-printer!
|
||||||
|
<frame>
|
||||||
|
(λ (record port)
|
||||||
|
(format port "#<<frame> header: ~a>" (frame-header record))))
|
||||||
|
|
||||||
(define-record-type <flac-metadata>
|
(define-record-type <flac-metadata>
|
||||||
(make-flac-metadata stream-info padding application seek-table vorbis-comment cuesheet pictures)
|
(make-flac-metadata stream-info padding application seek-table vorbis-comment cuesheet pictures)
|
||||||
flac-metadata?
|
flac-metadata?
|
||||||
|
|
|
@ -93,4 +93,6 @@
|
||||||
(let coded-number-loop ((coded-sample-number (flac-read-uint 8)))
|
(let coded-number-loop ((coded-sample-number (flac-read-uint 8)))
|
||||||
(if (< coded-sample-number #b11000000)
|
(if (< coded-sample-number #b11000000)
|
||||||
coded-sample-number
|
coded-sample-number
|
||||||
(coded-number-loop (bitwise-and (bitwise-arithmetic-shift coded-sample-number 1) #xff)))))
|
(begin
|
||||||
|
(flac-read-uint 8)
|
||||||
|
(coded-number-loop (bitwise-and (bitwise-arithmetic-shift coded-sample-number 1) #xff))))))
|
||||||
|
|
Loading…
Reference in New Issue