flac
Steve Ayerhart 2020-04-21 11:49:47 -05:00
parent c1fd2077a2
commit 77d5b75257
No known key found for this signature in database
GPG Key ID: 5BFD39C5359E967D
2 changed files with 20 additions and 7 deletions

View File

@ -1,6 +1,19 @@
! Copyright (C) 2009 Daniel Ehrenberg ! Copyright (C) 2009 Daniel Ehrenberg
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel ; USING: kernel system destructors accessors io.streams.duplex ;
IN: flac.bitstream IN: flac.bitstream
TUPLE: flac-bitstream < disposable
stream ;
HOOK: open-flac-bitstream os ( flac-bitstream -- flac-bitstream' )
M: flac-bitstream dispose* ( flac-bitstream -- ) stream>> dispose ;
: <flac-bitstream> ( path -- flac-bitstream )
flac-bitstream new
swap >>path ;
: with-flac-bitstream ( flac-bitstream quot -- )
[ open-flac-bitstream ] dip with-stream ; inline

View File

@ -64,19 +64,19 @@ ERROR: invalid-subframe-sync ;
: decode-bits-per-sample ( n -- n ) : decode-bits-per-sample ( n -- n )
{ {
{ 0b000 [ -99 ] } { 0b000 [ "TODO" ] }
{ 0b001 [ 8 ] } { 0b001 [ 8 ] }
{ 0b010 [ 12 ] } { 0b010 [ 12 ] }
{ 0b011 [ -99 ] } { 0b011 [ "TODO" ] }
{ 0b100 [ 16 ] } { 0b100 [ 16 ] }
{ 0b101 [ 20 ] } { 0b101 [ 20 ] }
{ 0b110 [ 24 ] } { 0b110 [ 24 ] }
{ 0b111 [ -99 ] } { 0b111 [ "TODO" ] }
} case ; } case ;
: decode-sample-rate ( n -- n ) : decode-sample-rate ( n -- n )
{ {
{ 0b0000 [ -99 ] } { 0b0000 [ "TODO" ] }
{ 0b0001 [ 88200 ] } { 0b0001 [ 88200 ] }
{ 0b0010 [ 17640 ] } { 0b0010 [ 17640 ] }
{ 0b0011 [ 19200 ] } { 0b0011 [ 19200 ] }
@ -138,7 +138,7 @@ ERROR: invalid-subframe-sync ;
} cond-case <flac-subframe-type> swap ; } cond-case <flac-subframe-type> swap ;
: read-residual ( order -- residual ) : read-residual ( order -- residual )
drop "TODO" ;
: read-constant-subframe ( frame-header subframe-header -- constant-subframe ) : read-constant-subframe ( frame-header subframe-header -- constant-subframe )
drop bits-per-sample>> 8 / read be> flac-subframe-constant boa ; drop bits-per-sample>> 8 / read be> flac-subframe-constant boa ;
@ -149,7 +149,7 @@ ERROR: invalid-subframe-sync ;
] map flac-subframe-fixed new swap >>warmup dup . ; ] map flac-subframe-fixed new swap >>warmup dup . ;
: read-lpc-subframe ( predictive-order -- lpc-subframe ) : read-lpc-subframe ( predictive-order -- lpc-subframe )
drop 9 ; drop "TODO" ;
:: decode-subframe-header ( bitstream -- subframe-header ) :: decode-subframe-header ( bitstream -- subframe-header )
1 bitstream read-bit 1 = [ invalid-subframe-sync ] when 1 bitstream read-bit 1 = [ invalid-subframe-sync ] when