Mercurial > hg > may
changeset 233:545a32830886
A more sophisticated bitdepth comparator, but something is still wrong here
author | Chris Cannam |
---|---|
date | Sun, 19 May 2013 18:42:10 +0100 |
parents | 67ff37b03856 |
children | 51c5ce72832e 6a141098c059 |
files | yetilab/stream/test/test_audiofile.yeti |
diffstat | 1 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/yetilab/stream/test/test_audiofile.yeti Fri May 17 20:24:44 2013 +0100 +++ b/yetilab/stream/test/test_audiofile.yeti Sun May 19 18:42:10 2013 +0100 @@ -26,15 +26,27 @@ esac; bitdepthComparator depth = - (mult = fold do a _: a*2 done 1 [1..depth]; - mult = mult / 2; - roundedBy f x = round (x * f); - do a b: - a' = roundedBy mult a; - b' = roundedBy mult b; - if abs(a' - b') <= 1 then true + (range = fold do a _: a*2 done 1 [1..depth]; // 2^depth + unsigned = (range == 8); + // Although for float->int conversion on writing we multiply by + // max-1 (e.g. by 32767 in 16-bit signed export), when reading we + // divide by 32768 -- in both cases trying to avoid overflow. For + // this comparison we get a test sample (read from a file) and a + // reference sample (synthesised locally) and we need to simulate + // the export process for the synthetic one while inverting the + // import process for the test sample. + do test ref: + test' = round + if unsigned then (test + 1) * range + else test * (range/2) + fi; + ref' = round + if unsigned then (ref * (range-1)) - (range/2) + else ref * (range/2 - 1) + fi; + if abs(test' - ref') <= 1 then true else - eprintln "bitdepthComparator: \(a) != \(b) at bitdepth \(depth) [\(a') != \(b')]"; + eprintln "bitdepthComparator: \(test) != \(ref) at bitdepth \(depth) [\(test') != \(ref')]"; false; fi; done); @@ -57,6 +69,7 @@ else println " channel \(ch): not ok"; // This isn't really simple enough! +/*!!! seriesFor m = Series { start = 0, @@ -64,6 +77,7 @@ values = take 1000 (vec.list (mat.getRow ch m)) }; \() (pl.plot (map seriesFor [ test, ref, mat.scaled 10000 (mat.difference test ref) ])); +*/ fi; done; false