Mercurial > hg > may
changeset 171:df2383f6b99b
Initial filter tests and combining filter
author | Chris Cannam |
---|---|
date | Thu, 02 May 2013 17:33:55 +0100 |
parents | 5a1db7299a08 |
children | f1c75782e56e |
files | yetilab/matrix/matrix.yeti yetilab/matrix/test/test_matrix.yeti yetilab/stream/filter.yeti yetilab/stream/test/test_filter.yeti yetilab/test/all.yeti yetilab/vamp/vamp.yeti |
diffstat | 6 files changed, 87 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/yetilab/matrix/matrix.yeti Thu May 02 11:27:20 2013 +0100 +++ b/yetilab/matrix/matrix.yeti Thu May 02 17:33:55 2013 +0100 @@ -168,10 +168,10 @@ fi; asRows m = - map (block.list . m.getRow) [0 .. m.size.rows - 1]; + map m.getRow [0 .. m.size.rows - 1]; asColumns m = - map (block.list . m.getColumn) [0 .. m.size.columns - 1]; + map m.getColumn [0 .. m.size.columns - 1]; { constMatrix, randomMatrix, zeroMatrix, identityMatrix, zeroSizeMatrix,
--- a/yetilab/matrix/test/test_matrix.yeti Thu May 02 11:27:20 2013 +0100 +++ b/yetilab/matrix/test/test_matrix.yeti Thu May 02 17:33:55 2013 +0100 @@ -266,13 +266,15 @@ "asRows-\(name)": \( compare - (mat.asRows (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,6]])) + (map block.list + (mat.asRows (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,6]]))) [[1,2,3],[4,5,6]]; ), "asColumns-\(name)": \( compare - (mat.asColumns (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,6]])) + (map block.list + (mat.asColumns (newMatrix (ColumnMajor ()) [[1,4],[2,5],[3,6]]))) [[1,4],[2,5],[3,6]]; ),
--- a/yetilab/stream/filter.yeti Thu May 02 11:27:20 2013 +0100 +++ b/yetilab/stream/filter.yeti Thu May 02 17:33:55 2013 +0100 @@ -5,7 +5,25 @@ load yetilab.stream.streamtype; -truncatedTo nsamples s = +minDurationOf d1 d2 = + case d1 of + Known a: + case d2 of + Known b: Known (min a b); + Unknown (): Unknown (); + Infinite (): Known a; + esac; + Unknown (): + case d2 of + Known b: Known b; + Unknown (): Unknown (); + Infinite (): Unknown (); + esac; + Infinite (): + d2; + esac; + +truncatedTo nsamples s = //!!! should nsamples be a time in seconds? { get position () = s.position, get channels () = s.channels, @@ -23,8 +41,30 @@ close = s.close, }; + +//!!! not really mixed -- what's the word for it? one per channel +mixed s1 s2 = //!!! could generalise to list of streams + { + get position () = s1.position, + get channels () = s1.channels + s2.channels, + get sampleRate () = s1.sampleRate, + get available () = minDurationOf s1.available s2.available, + get finished? () = s1.finished? or s2.finished?, + read count = + (outs = map do s: s.read count done [ s1, s2 ]; + minlen = head (sort (map do m: m.size.columns done outs)); + outs = map do m: + mat.resizedTo { rows = m.size.rows, columns = minlen } m + done outs; + mat.newMatrix (RowMajor ()) + (concat (map mat.asRows outs)) + ), + close = (s1.close (); s2.close ()) + }; + { truncatedTo, + mixed, //!!!} as { // truncatedTo is number -> stream -> stream }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/yetilab/stream/test/test_filter.yeti Thu May 02 17:33:55 2013 +0100 @@ -0,0 +1,38 @@ + +module yetilab.stream.test.test_filter; + +bl = load yetilab.block.block; +mat = load yetilab.matrix.matrix; +syn = load yetilab.stream.syntheticstream; +filt = load yetilab.stream.filter; + +{ compare, compareUsing } = load yetilab.test.test; + +[ + +"truncatedTo": \( + // nb the basic generated function is tested in test_syntheticstream + str = filt.truncatedTo 3 (syn.generated 2 id); + compare str.position 0 and + compare str.channels 1 and + compare str.sampleRate 2 and + compare str.available (Known 3) and + compare str.finished? false and + compare (bl.list ((str.read 4).getRow 0)) [ 0, 0.5, 1 ] and + compare str.position 3 +), + +"mixed-inf-inf": \( + str = filt.mixed (syn.generated 2 id) (syn.generated 2 (0-)); + compare str.position 0 and + compare str.channels 2 and + compare str.sampleRate 2 and + compare str.available (Infinite ()) and + compare str.finished? false and + compare (map bl.list (mat.asRows (str.read 4))) [[0,1,2,3], [0,-1,-2,-3]] and + compare str.available (Infinite ()) and + compare str.position 4 +), + +] is hash<string, () -> boolean> +
--- a/yetilab/test/all.yeti Thu May 02 11:27:20 2013 +0100 +++ b/yetilab/test/all.yeti Thu May 02 17:33:55 2013 +0100 @@ -11,6 +11,7 @@ "channels" : load yetilab.stream.test.test_channels, "audiofile" : load yetilab.stream.test.test_audiofile, "synstream" : load yetilab.stream.test.test_syntheticstream, +"filter" : load yetilab.stream.test.test_filter, "fft" : load yetilab.transform.test.test_fft, "vamppost" : load yetilab.vamp.test.test_vamppost, "vamp" : load yetilab.vamp.test.test_vamp,
--- a/yetilab/vamp/vamp.yeti Thu May 02 11:27:20 2013 +0100 +++ b/yetilab/vamp/vamp.yeti Thu May 02 17:33:55 2013 +0100 @@ -209,7 +209,7 @@ None (): map (outputDescriptor (None ())) p#getOutputDescriptors(); esac, process frame time is 'a -> ~RealTime -> 'b = - featureSet p#process((mat.asRows frame) as ~float[][], 0, time), + featureSet p#process((map bl.floats (mat.asRows frame)) as ~float[][], 0, time), getRemainingFeatures () = featureSet p#getRemainingFeatures(), dispose () = p#dispose(), });