changeset 230:a8c84f59f7c0

Print out the offending channel
author Chris Cannam
date Sun, 12 May 2013 21:12:54 +0100
parents ac1373067054
children 67ff37b03856
files yetilab/stream/test/test_audiofile.yeti
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/yetilab/stream/test/test_audiofile.yeti	Sun May 12 18:04:48 2013 +0100
+++ b/yetilab/stream/test/test_audiofile.yeti	Sun May 12 21:12:54 2013 +0100
@@ -26,12 +26,12 @@
 
 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;
+    roundedBy f x = round (x * f);
     do a b:
-        a' = int (a * mult);
-        b' = int (b * mult);
-        if a' == b' then true
+        a' = roundedBy mult a;
+        b' = roundedBy mult b;
+        if abs(a' - b') <= 1 then true
         else 
             eprintln "bitdepthComparator: \(a) != \(b) at bitdepth \(depth) [\(a') != \(b')]";
             false;
@@ -48,6 +48,15 @@
         true
     else
         println "** peak difference: \(maxOf (mat.difference ref test))";
+        for [0..mat.height test - 1] do ch:
+            if mat.equalUnder (bitdepthComparator bitdepth)
+               (mat.newRowVector (mat.getRow ch test))
+               (mat.newRowVector (mat.getRow ch ref)) then
+                println "   channel \(ch): ok";
+            else
+                println "   channel \(ch): not ok";
+            fi;
+        done;
         false
     fi);