Mercurial > hg > may
changeset 364:99103233707a
Test for spaced
author | Chris Cannam |
---|---|
date | Fri, 12 Jul 2013 10:33:43 +0100 |
parents | 87c25c94e4ed |
children | de59b3504455 |
files | may/stream/filter.yeti may/stream/test/test_filter.yeti |
diffstat | 2 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/may/stream/filter.yeti Fri Jul 12 10:13:08 2013 +0100 +++ b/may/stream/filter.yeti Fri Jul 12 10:33:43 2013 +0100 @@ -441,7 +441,12 @@ { get position () = pos, get available () = - case s.available of Known n: Known (n*mult); other: other esac, + case s.available of + Known n: + (pending = case (pos % mult) of 0: 0; n: (mult - n) esac; + Known (pending + (n * mult))); + other: other + esac, read n = (readOne () = (offset = pos % mult;
--- a/may/stream/test/test_filter.yeti Fri Jul 12 10:13:08 2013 +0100 +++ b/may/stream/test/test_filter.yeti Fri Jul 12 10:33:43 2013 +0100 @@ -7,7 +7,9 @@ syn = load may.stream.syntheticstream; filt = load may.stream.filter; -pl = load may.plot;//!!! +//pl = load may.plot;//!!! + +pl = { plot things = true; }; { compare, compareUsing } = load may.test.test; @@ -619,6 +621,29 @@ done convolutionOptions); ), +"spaced-\(name)": \( + original = maybeDuration 3 (syn.precalculatedMono 2 (vec.fromList [1,2,3])); + str = filt.spaced 3 original; + compare str.position 0 and + compare str.channels 1 and + compare str.sampleRate 2 and + compare str.available (maybeKnown 9) and + compare str.finished? false and + compare (map vec.list (mat.asRows (str.read 4))) [[1,0,0,2]] and + compare str.position 4 and + compare str.available (maybeKnown 5) and + compare str.finished? false and + compare (map vec.list (mat.asRows (str.read 1))) [[0]] and + compare str.position 5 and + compare str.available (maybeKnown 4) and + compare str.finished? false and + compare (map vec.list (mat.asRows (str.read 10))) [[0,3,0,0]] and + compare str.position 9 and + compare str.available (Known 0) and + compare str.finished? true and + ( str.close (); true ) +), + "interpolated-sine-\(name)": \( // Interpolating a sinusoid should give us a sinusoid sinusoid = syn.sinusoid 8 2; // 2Hz sine sampled at 8Hz: [ 0, 1, 0, -1 ] etc