changeset 169:fb0000d15b53

readMono fix (must still return matrix even though it's only one channel)
author Chris Cannam
date Thu, 02 May 2013 09:56:53 +0100
parents 45199077b043
children 5a1db7299a08
files yetilab/stream/audiofile.yeti yetilab/stream/test/test_audiofile.yeti
diffstat 2 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/yetilab/stream/audiofile.yeti	Thu May 02 09:29:10 2013 +0100
+++ b/yetilab/stream/audiofile.yeti	Thu May 02 09:56:53 2013 +0100
@@ -79,7 +79,7 @@
 readMono' { format is ~AudioFormat, aistream is ~AudioInputStream } n =
    (b = readInterleaved' { format, aistream } n;
     channels = format#getChannels();
-    ch.mixedDownFromInterleaved channels b;
+    ch.deinterleaved 1 (ch.mixedDownFromInterleaved channels b);
    );
 
 // Note, all this assumes aistream is non-blocking (i.e. available()
--- a/yetilab/stream/test/test_audiofile.yeti	Thu May 02 09:29:10 2013 +0100
+++ b/yetilab/stream/test/test_audiofile.yeti	Thu May 02 09:56:53 2013 +0100
@@ -27,15 +27,17 @@
 ),
 
 "20samples-read": \(
-    f = af.open (testfile "20samples");
-    first15 = f.read 15;
-    last5 = f.read 10;
-    compare first15.size { rows = 1, columns = 15 } and
-        compare last5.size { rows = 1, columns = 5 } and
-        compare (bl.list (first15.getRow 0))
-            [ float (32767/32768),0,0,0,0,0,0,0,0,0,0,0,0,0,0 ] and
-        compare (bl.list (last5.getRow 0)) [ 0,0,0,0,-1 ] and
-        ( f.close () ; true )
+    all id (map do opener:
+        f = opener (testfile "20samples");
+        first15 = f.read 15;
+        last5 = f.read 10;
+        compare first15.size { rows = 1, columns = 15 } and
+            compare last5.size { rows = 1, columns = 5 } and
+            compare (bl.list (first15.getRow 0))
+                [ float (32767/32768),0,0,0,0,0,0,0,0,0,0,0,0,0,0 ] and
+            compare (bl.list (last5.getRow 0)) [ 0,0,0,0,-1 ] and
+            ( f.close () ; true )
+        done [ af.open, af.openMono ]);
 ),
 
 ] is hash<string, () -> boolean>