working decoder?

main
Steve Ayerhart 2022-08-13 19:38:54 -04:00
parent 3b96fbc28d
commit 008d217286
No known key found for this signature in database
GPG Key ID: 4CB33EB9BB156C97
4 changed files with 28 additions and 6 deletions

View File

@ -44,6 +44,7 @@
(iota (frame-header-blocksize header)))))
(define (decode-flac-file infile outfile)
(let ((old-output (current-output-port)))
(with-input-from-file infile
(λ ()
(with-flac-input-port (current-input-port)
@ -87,4 +88,20 @@
(write-frame frame (stream-info-channels stream-info))
(frame-loop (+ 1 frame-number)
(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))))))))

View File

@ -114,7 +114,7 @@
(parameters '())
(raw-bits '())
(residual '()))
(if (= partition partitions)
(if (>= partition partitions)
(values (%make-entropy-coding-method
coding-method
(%make-rice-partition

View File

@ -120,7 +120,6 @@
(header subframe-header)
(data subframe-data))
(define-record-type <subframe-lpc>
(%make-subframe-lpc entropy-coding-method order qlp-coefficient-precision quantization-level qlp-coefficients warmup residual)
subframe-lpc?
@ -169,7 +168,6 @@
(type entropy-coding-method-type)
(data entropy-coding-method-data))
(define-record-type <frame-header>
(make-frame-header blocking-strategy blocksize sample-rate channel-assignment bits-per-sample frame/sample-number crc)
frame-header?
@ -332,6 +330,11 @@
(λ (record port)
(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>
(make-flac-metadata stream-info padding application seek-table vorbis-comment cuesheet pictures)
flac-metadata?

View File

@ -93,4 +93,6 @@
(let coded-number-loop ((coded-sample-number (flac-read-uint 8)))
(if (< coded-sample-number #b11000000)
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))))))