# HG changeset patch # User Chris Cannam # Date 1393835565 0 # Node ID b75c0eaaa6dd756da2d731d599702eb40680c1d2 # Parent d6dd6e1cc00e60ab5aa012e6762875c802250893 Allow wrong max in alternate columns where expected max would be in lower octave (which is not present) diff -r d6dd6e1cc00e -r b75c0eaaa6dd yeti/test_cqtkernel.yeti --- a/yeti/test_cqtkernel.yeti Fri Feb 28 17:18:54 2014 +0000 +++ b/yeti/test_cqtkernel.yeti Mon Mar 03 08:32:45 2014 +0000 @@ -11,7 +11,7 @@ k = makeKernel { sampleRate = 16, maxFreq = 8, binsPerOctave = 4 }; print k; cm.print k.kernel; -true; +false; ), ] is hash boolean> diff -r d6dd6e1cc00e -r b75c0eaaa6dd yeti/test_frequency.yeti --- a/yeti/test_frequency.yeti Fri Feb 28 17:18:54 2014 +0000 +++ b/yeti/test_frequency.yeti Mon Mar 03 08:32:45 2014 +0000 @@ -32,13 +32,21 @@ testFreqs = map (* 5) [ 0..10 ]; duration = sampleRate * 2; -threshold = 0.05; +threshold = 0.08; streamBuilder = sinTestStream sampleRate duration; binForFreq f = mm.round (bpo * mm.log2 (f / cqmin)) - 1; +report message matrix = + (eprintln message; + eprintln "matrix is:"; + mat.eprint matrix; + chart = plot.plot [Grid matrix]; + sleep 100; + chart#dispose()); + tests = mapIntoHash do f: "freq_\(f)" done do f: \( @@ -50,22 +58,30 @@ var colno = 0; success = all id (map do c: - // passes test if the correct max bin, or the expected max - // is out of range, or if all bins are below a threshold + // The test passes for this column if: + // + // * the max bin is the expected one, or + // + // * the expected max is out of range entirely (but + // we need to test _something_ in this case -- + // what?), or + // + // * all bins are below a threshold, or + // + // * this is an odd column and the expected max is in + // the lower octave + // + // We should also check that all values in the lower + // octave are zero for odd columns. + // expected = binForFreq f; good = (expected < 0 or expected >= vec.length c) or + ((colno % 2 == 1) and expected < (vec.length c / 2)) or (vec.max c < threshold) or (vec.maxindex c == binForFreq f); if (not good) then - println " * bad! maxindex \(vec.maxindex c) != expected \(binForFreq f) for freq \(f) in column \(colno) of \(mat.width m): column is \(vec.list c)"; - println "matrix is:"; - mat.print m; - chart = plot.plot [Grid m]; - sleep 100; - chart#dispose(); - else - print "✓"; + report " * bad! maxindex \(vec.maxindex c) != expected \(binForFreq f) for freq \(f) in column \(colno) of \(mat.width m): column is \(vec.list c)" m; fi; colno := colno + 1; good;