changeset 32:025c88d62f7a

blocksize -> framesize in framer
author Chris Cannam
date Fri, 21 Dec 2012 13:32:03 +0000
parents 102945485663
children e20d3c23a243
files framer.yeti test/test_framer.yeti
diffstat 2 files changed, 32 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/framer.yeti	Fri Dec 21 13:31:10 2012 +0000
+++ b/framer.yeti	Fri Dec 21 13:32:03 2012 +0000
@@ -10,25 +10,25 @@
 block = load block;
 af = load audiofile;
 
-blockList blocksize stream =
+blockList framesize stream =
     if stream.finished? then
        (stream.close (); [] );
     else
-        block.resizedTo blocksize (stream.readMono blocksize)
-            :. \(blockList blocksize stream);
+        block.resizedTo framesize (stream.readMono framesize)
+            :. \(blockList framesize stream);
     fi;
 
-overlappingBlockList bs hop stream valid buffer
+overlappingBlockList size hop stream valid buffer
     is number -> number -> 'a -> number -> ~double[] -> 'b =
    (
     b = stream.readMono hop;
     obtained = block.length b;
     samples = block.unblock b;
 
-    // Retain blocksize - hop samples from old buffer, add hop samples
+    // Retain framesize - hop samples from old buffer, add hop samples
     // (zero-padded if necessary) just read
     buffer = vec.concat
-       (vec.rangeOf buffer hop (bs-hop))
+       (vec.rangeOf buffer hop (size-hop))
        (vec.resizedTo hop samples);
 
     // Number of "valid" elements (not tail-end zero-padding) left in buffer
@@ -39,23 +39,23 @@
         [];
     else
         v = block.block buffer;
-        v :. \(overlappingBlockList bs hop stream remaining buffer);
+        v :. \(overlappingBlockList size hop stream remaining buffer);
     fi);
 
-frames { blocksize, hop } stream =
-    if blocksize == hop then
-        blockList blocksize stream
+frames { framesize, hop } stream =
+    if framesize == hop then
+        blockList framesize stream
     else
-        overlappingBlockList blocksize hop stream 
-            blocksize (vec.zeros blocksize);
+        overlappingBlockList framesize hop stream 
+            framesize (vec.zeros framesize);
     fi;
 
-framesOfFile { blocksize, hop } filename =
-    if blocksize == hop then
-        blockList blocksize (af.open filename)
+framesOfFile { framesize, hop } filename =
+    if framesize == hop then
+        blockList framesize (af.open filename)
     else
-        overlappingBlockList blocksize hop (af.open filename)
-            blocksize (vec.zeros blocksize);
+        overlappingBlockList framesize hop (af.open filename)
+            framesize (vec.zeros framesize);
     fi;
 
 { 
--- a/test/test_framer.yeti	Fri Dec 21 13:31:10 2012 +0000
+++ b/test/test_framer.yeti	Fri Dec 21 13:32:03 2012 +0000
@@ -8,80 +8,80 @@
 tests = [
 
 "framecount-2x2": \( 
-    fr = fr.frames { blocksize = 2, hop = 2 } (test.testStream 2);
+    fr = fr.frames { framesize = 2, hop = 2 } (test.testStream 2);
     test.compare (length fr) 1
 ),
 
 "framecount-2x3": \( 
-    fr = fr.frames { blocksize = 2, hop = 2 } (test.testStream 3);
+    fr = fr.frames { framesize = 2, hop = 2 } (test.testStream 3);
     test.compare (length fr) 2
 ),
 
 "framecount-2x4": \( 
-    fr = fr.frames { blocksize = 2, hop = 2 } (test.testStream 4);
+    fr = fr.frames { framesize = 2, hop = 2 } (test.testStream 4);
     test.compare (length fr) 2
 ),
 
 "framecount-2.1x0": \( 
-    fr = fr.frames { blocksize = 2, hop = 1 } (test.testStream 0);
+    fr = fr.frames { framesize = 2, hop = 1 } (test.testStream 0);
     test.compare (length fr) 1
 ),
 
 "framecount-2.1x1": \( 
-    fr = fr.frames { blocksize = 2, hop = 1 } (test.testStream 1);
+    fr = fr.frames { framesize = 2, hop = 1 } (test.testStream 1);
     test.compare (length fr) 2
 ),
 
 "framecount-2.1x2": \( 
-    fr = fr.frames { blocksize = 2, hop = 1 } (test.testStream 2);
+    fr = fr.frames { framesize = 2, hop = 1 } (test.testStream 2);
     test.compare (length fr) 3
 ),
 
 "framecount-2.1x3": \( 
-    fr = fr.frames { blocksize = 2, hop = 1 } (test.testStream 3);
+    fr = fr.frames { framesize = 2, hop = 1 } (test.testStream 3);
     test.compare (length fr) 4
 ),
 
 "framecount-4.1x4": \( 
-    fr = fr.frames { blocksize = 4, hop = 1 } (test.testStream 4);
+    fr = fr.frames { framesize = 4, hop = 1 } (test.testStream 4);
     test.compare (length fr) 7
 ),
 
 "framecount-4.3x4": \( 
-    fr = fr.frames { blocksize = 4, hop = 3 } (test.testStream 4);
+    fr = fr.frames { framesize = 4, hop = 3 } (test.testStream 4);
     test.compare (length fr) 2 
 ),
 
 "framecount-4.4x4": \( 
-    fr = fr.frames { blocksize = 4, hop = 4 } (test.testStream 4);
+    fr = fr.frames { framesize = 4, hop = 4 } (test.testStream 4);
     test.compare (length fr) 1
 ),
 
 "framecount-3.2x4": \(
-    fr = fr.frames { blocksize = 3, hop = 2 } (test.testStream 4);
+    fr = fr.frames { framesize = 3, hop = 2 } (test.testStream 4);
     test.compare (length fr) 3
 ),
 
 "frames-2x5": \( 
-    fr = fr.frames { blocksize = 2, hop = 2 } (test.testStream 5);
+    fr = fr.frames { framesize = 2, hop = 2 } (test.testStream 5);
     expected = [ [1,2], [3,4], [5,0] ];
     test.compare (map block.list fr) expected;
 ),
 
 "frames-4.3x4": \( 
-    fr = fr.frames { blocksize = 4, hop = 3 } (test.testStream 4);
+    fr = fr.frames { framesize = 4, hop = 3 } (test.testStream 4);
     expected = [ [0,1,2,3], [3,4,0,0] ];
     test.compare (map block.list fr) expected;
 ),
 
 "frames-3.2x4": \(
-    fr = fr.frames { blocksize = 3, hop = 2 } (test.testStream 4);
+    fr = fr.frames { framesize = 3, hop = 2 } (test.testStream 4);
     expected = [ [0,1,2], [2,3,4], [4,0,0] ];
     test.compare (map block.list fr) expected;
 ),
 
 "frames-3.1x6": \(
-    fr = fr.frames { blocksize = 3, hop = 1 } (test.testStream 6);
+    fr = fr.frames { framesize = 3, hop = 1 } (test.testStream 6);
     expected = [ [0,0,1], [0,1,2], [1,2,3], [2,3,4],
                  [3,4,5], [4,5,6], [5,6,0], [6,0,0] ];
     test.compare (map block.list fr) expected;