# HG changeset patch # User Chris Cannam # Date 1395054586 0 # Node ID 9dee3846562bafb558a8f870f9fb59137467121a # Parent 6ad790af9c884b9b3e4b3f32e973a83af177b05b Finally fix the tests for reconstruction of unpadded overlapping frames diff -r 6ad790af9c88 -r 9dee3846562b src/may/stream/test/test_framer.yeti --- 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