]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/audio/aiff/aiff.factor
factor: trim using lists
[factor.git] / extra / audio / aiff / aiff.factor
index 549134003b628425087304faa368c20868bd0240..662cc5d2ebdd8bef2e4b208d4af8ad54a338c8df 100644 (file)
@@ -1,9 +1,9 @@
-! (c)2009 Joe Groff bsd license
+! Copyright (C) 2009 Joe Groff.
+! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data audio
-audio.chunked-file classes.struct combinators
-combinators.short-circuit endian io io.binary
-io.encodings.binary io.files kernel locals math sequences
-audio.loader ;
+audio.chunked-file audio.loader classes.struct combinators
+combinators.short-circuit endian io.encodings.binary io.files
+kernel math sequences ;
 IN: audio.aiff
 
 CONSTANT: FORM-MAGIC "FORM"
@@ -34,8 +34,7 @@ STRUCT: sound-data-chunk
 
 ! cheesy long-double>integer converter that assumes the long double is a positive integer
 : sample-rate>integer ( byte[10] -- sample-rate )
-    [ 2 tail-slice be> ]
-    [ 2 head-slice be> 16383 - 63 - ] bi shift ;
+    2 cut-slice [ be> ] bi@ swap 16383 - 63 - shift ;
 
 : read-form-chunk ( -- byte-array/f )
     form-chunk heap-size ensured-read* ;
@@ -43,7 +42,7 @@ STRUCT: sound-data-chunk
 : verify-aiff ( chunk -- )
     {
         [ FORM-MAGIC id= ]
-        [ form-chunk memory>struct form-type>> 4 memory>byte-array AIFF-MAGIC id= ] 
+        [ form-chunk memory>struct form-type>> 4 memory>byte-array AIFF-MAGIC id= ]
     } 1&&
     [ invalid-audio-file ] unless ;