Mercurial > hg > may
view yetilab/stream/test/test_syntheticstream.yeti @ 218:a7f4eb1cdd72 matrix_opaque_immutable
More block -> vector
author | Chris Cannam |
---|---|
date | Sat, 11 May 2013 12:04:05 +0100 |
parents | 26111c11d8e4 |
children | 77c6a81c577f |
line wrap: on
line source
module yetilab.stream.test.test_syntheticstream; vec = load yetilab.block.vector; mat = load yetilab.matrix.matrix; syn = load yetilab.stream.syntheticstream; { compare, compareUsing } = load yetilab.test.test; compareApprox eps = compareUsing do v1 v2: all id (map2 do f1 f2: abs (f1 - f2) < eps done v1 v2) done; epsilon = 0.000001; [ "generated": \( str = syn.generated 2 id; compare str.position 0 and compare str.channels 1 and compare str.sampleRate 2 and compare str.available (Infinite ()) and compare str.finished? false and compare (vec.list (mat.getRow 0 (str.read 4))) [ 0,1,2,3 ] and compare str.position 4 ), "sinusoid": \( // 2Hz sine sampled 8 times a second str = syn.sinusoid 8 2; compare str.position 0 and compare str.channels 1 and compare str.sampleRate 8 and compare str.available (Infinite ()) and compare str.finished? false and compareApprox epsilon (vec.list (mat.getRow 0 (str.read 6))) [ 0, 1, 0, -1, 0, 1 ] and compare str.position 6 ), "silent": \( str = syn.silent 8; compare str.position 0 and compare str.channels 1 and compare str.sampleRate 8 and compare str.available (Infinite ()) and compare str.finished? false and compare (vec.list (mat.getRow 0 (str.read 3))) [ 0, 0, 0 ] and compare str.position 3 ), "precalculated-empty": \( str = syn.precalculated 2 (vec.fromList []); compare str.position 0 and compare str.channels 1 and compare str.sampleRate 2 and compare str.available (Known 0) and compare str.finished? true and compare (vec.list (mat.getRow 0 (str.read 3))) [] and compare str.position 0 ), "precalculated": \( str = syn.precalculated 2 (vec.fromList [ 1, 2, 3, 4 ]); compare str.position 0 and compare str.channels 1 and compare str.sampleRate 2 and compare str.available (Known 4) and compare str.finished? false and compare (vec.list (mat.getRow 0 (str.read 3))) [ 1, 2, 3 ] and compare str.position 3 and compare str.available (Known 1) and compare str.finished? false and compare (vec.list (mat.getRow 0 (str.read 3))) [ 4 ] and compare str.position 4 and compare str.available (Known 0) and compare str.finished? true ), ] is hash<string, () -> boolean>