# HG changeset patch # User Chris Cannam # Date 1368366635 -3600 # Node ID 055a0a5500d75fc5aa6e1eed4bc01bd680e496d8 # Parent c00d8f7e27082b312597b6c06f739f37a2a5f095 Try comparison at file bitdepth (not working quite correctly) diff -r c00d8f7e2708 -r 055a0a5500d7 yetilab/stream/test/test_audiofile.yeti --- 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); [