Mercurial > hg > may
changeset 289:b34960d2b519
More overlap-add tests.
author | Chris Cannam |
---|---|
date | Thu, 30 May 2013 22:33:16 +0100 |
parents | 16a9ee99efcf |
children | 21ec05237c1a |
files | yetilab/stream/framer.yeti yetilab/stream/test/test_framer.yeti |
diffstat | 2 files changed, 27 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/yetilab/stream/framer.yeti Thu May 30 20:27:54 2013 +0100 +++ b/yetilab/stream/framer.yeti Thu May 30 22:33:16 2013 +0100 @@ -121,15 +121,7 @@ get channels () = channels, get sampleRate () = rate, get finished? () = empty? remaining and mat.empty? buffered, - get available () = - // Don't take length of frames: we don't want to lose - // laziness. If the caller cares that much, they can - // measure frames themselves - if empty? remaining then - Known (mat.width buffered) - else - Unknown () - fi, + get available () = Unknown (), read count = (framesFor samples acc = if samples <= 0 or empty? remaining then @@ -142,7 +134,6 @@ fi; source = overlapAdd channels framesize hop (framesFor count [buffered]); -// println "source = \(source)"; toReturn = mat.columnSlice source 0 count; position := position + mat.width toReturn; buffered := mat.columnSlice source count (mat.width source);
--- a/yetilab/stream/test/test_framer.yeti Thu May 30 20:27:54 2013 +0100 +++ b/yetilab/stream/test/test_framer.yeti Thu May 30 22:33:16 2013 +0100 @@ -16,24 +16,35 @@ all id (map2 do f1 f2: compareUsing mat.equal f1 f2 done frames1 (map (mat.newRowVector . vec.fromList) frames2)); -testFrames parameters length expected = - (f = fr.frames parameters (testStream length); - str = fr.streamed rate parameters f; - sz = parameters.framesize; +testFramesWith params length expected firstChunkSize = + (f = fr.frames params (testStream length); + str = fr.streamed rate params f; + sz = params.framesize; ts = testStream length; + + overlapping = params.framesize > params.hop; + incomplete = overlapping and // Can't reconstruct with < 50% overlap + params.framesize < params.hop * 2; + + firstChunk = str.read firstChunkSize; + restChunk = str.read (length - firstChunkSize); + + println "firstChunkSize = \(firstChunkSize)"; + compareFrames f expected and - compareUsing mat.equal - (str.read length) (ts.read length) and + (incomplete or + compareUsing mat.equal + firstChunk (ts.read firstChunkSize)) and + (incomplete or + compareUsing mat.equal + restChunk (ts.read (length - firstChunkSize))) and compare str.position length and - compare str.available (Known (sz - (length % sz)))); -/* - compareUsing mat.equal - (str.read 2) (ts.read 2) and - compareUsing mat.equal - (str.read (length - 2)) (ts.read (length - 2)) and - compare str.position length and - compare str.available (Known (sz - (length % sz)))); -*/ + (overlapping or // (overlapping streamer doesn't know when it'll end!) + compare str.available (Known (sz - (length % sz))))); + +testFrames params length expected = + all id (map (testFramesWith params length expected) [1..length]); + [ "framecount-2x2": \(