changeset 227:055a0a5500d7

Try comparison at file bitdepth (not working quite correctly)
author Chris Cannam
date Sun, 12 May 2013 14:50:35 +0100
parents c00d8f7e2708
children 1b02d903aa79
files yetilab/stream/test/test_audiofile.yeti
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/yetilab/stream/test/test_audiofile.yeti	Sun May 12 14:50:03 2013 +0100
+++ b/yetilab/stream/test/test_audiofile.yeti	Sun May 12 14:50:35 2013 +0100
@@ -23,10 +23,24 @@
     _: failWith "Known-duration stream required";
     esac;
 
+bitdepthComparator depth =
+   (mult = fold do a _: a*2 done 1 [1..depth];
+    // We compare at depth-1 rather than depth to avoid rounding problems
+    mult = mult / 2;
+    do a b:
+        a' = int (a * mult);
+        b' = int (b * mult);
+        if a' == b' then true
+        else 
+            eprintln "bitdepthComparator: \(a) != \(b) at bitdepth \(depth) [\(a') != \(b')]";
+            false;
+        fi;
+    done);
+
 testReferenceFile rate channels bitdepth =
    (test = readAll (af.open (testfile "\(rate)-\(channels)-\(bitdepth)"));
     ref = readAll (ref.afReference rate channels);
-    compareUsing mat.equal test ref);
+    compareUsing (mat.equalUnder (bitdepthComparator bitdepth)) test ref);
 
 [