Mercurial > hg > may
changeset 534:9dee3846562b
Finally fix the tests for reconstruction of unpadded overlapping frames
author | Chris Cannam |
---|---|
date | Mon, 17 Mar 2014 11:09:46 +0000 |
parents | 6ad790af9c88 |
children | d8a967b0f909 |
files | src/may/stream/test/test_framer.yeti |
diffstat | 1 files changed, 26 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/may/stream/test/test_framer.yeti Fri Mar 14 16:27:14 2014 +0000 +++ b/src/may/stream/test/test_framer.yeti Mon Mar 17 11:09:46 2014 +0000 @@ -5,6 +5,7 @@ vec = load may.vector; mat = load may.matrix; syn = load may.stream.syntheticstream; +win = load may.signal.window; { compare, compareUsing } = load may.test; @@ -12,6 +13,30 @@ testStream n is number -> 'a = syn.precalculatedMono rate (vec.fromList [1..n]); +expectedStream framesize opts n = + (var padded = true; + var hop = framesize; + for opts \case of + Padded p: padded := p; + Hop h: hop := h; + _: (); + esac; + if padded or (hop == framesize) then + testStream n + else + // Unpadded streams can't be perfectly reconstructed from + // windowed frames: the first framesize-hop samples will + // remain windowed (and scaled by the overlap-add) + m = framesize - hop; + factor = hop / (framesize/2); + w = vec.scaled factor (win.hann framesize); + syn.precalculatedMono rate + (vec.concat [ + vec.multiply (vec.fromList [1..m]) (vec.slice w 0 m), + vec.fromList [m+1..n] + ]) + fi); + compareFrames frames1 frames2 = all id (map2 do f1 f2: compareUsing mat.equal f1 f2 done frames1 (map (mat.newRowVector . vec.fromList) frames2)); @@ -19,7 +44,7 @@ testFramesInvertibleWith framesize opts length expected firstChunkSize = (f = fr.frames framesize opts (testStream length); str = fr.streamed rate framesize opts f; - ts = testStream length; // newly initialised stream + ts = expectedStream framesize opts length; (firstChunk = str.read firstChunkSize; compareUsing mat.equal