Mercurial > hg > may
changeset 207:cd2caf235e1f
Fix mixing functions
author | Chris Cannam |
---|---|
date | Tue, 07 May 2013 21:43:10 +0100 |
parents | 0a61f84c6a8f |
children | 9997752223b8 51af10e6cd0d |
files | yetilab/stream/channels.yeti yetilab/stream/test/test_channels.yeti yetilab/stream/test/test_filter.yeti |
diffstat | 3 files changed, 10 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/yetilab/stream/channels.yeti Tue May 07 21:36:43 2013 +0100 +++ b/yetilab/stream/channels.yeti Tue May 07 21:43:10 2013 +0100 @@ -34,7 +34,7 @@ mat.newMatrix (RowMajor ()) (map block.block vv); fi; -mixedDown m = +mixedDown m = //!!! sum or average? at the moment we sum ({ columns, rows } = m.size; v = vec.zeros columns; for [0..rows-1] do row: @@ -81,15 +81,14 @@ fi; mixedTo targetChannels m = - if targetChannels == 1 then + if targetChannels == m.size.rows then // n -> n: pass unmodified + m + elif targetChannels == 1 then // n -> 1: mix down deinterleaved 1 (mixedDown m) - else - mat.resizedTo { rows = targetChannels, columns = m.size.columns } - if m.size.rows == 1 then - (mat.newMatrix (RowMajor ()) [ m.getRow 0, m.getRow 0 ]) - else - m - fi; + elif m.size.rows == 1 then // 1 -> n: copy to all channels + mat.newMatrix (RowMajor ()) (map \(m.getRow 0) [1..targetChannels]) + else // n -> m: truncate or add zeros + mat.resizedTo { rows = targetChannels, columns = m.size.columns } m fi; mixedAndInterleavedTo targetChannels m =
--- a/yetilab/stream/test/test_channels.yeti Tue May 07 21:36:43 2013 +0100 +++ b/yetilab/stream/test/test_channels.yeti Tue May 07 21:43:10 2013 +0100 @@ -69,7 +69,7 @@ compareBlocks (ch.mixedAndInterleavedTo 2 (newMatrix [[1],[2],[3]])) (bl.fromList [1,1,2,2,3,3]) and compareBlocks (ch.mixedAndInterleavedTo 3 (newMatrix [[1],[2],[3]])) - (bl.fromList [1,1,0,2,2,0,3,3,0]) + (bl.fromList [1,1,1,2,2,2,3,3,3]) ), ] is hash<string, () -> boolean>;
--- a/yetilab/stream/test/test_filter.yeti Tue May 07 21:36:43 2013 +0100 +++ b/yetilab/stream/test/test_filter.yeti Tue May 07 21:43:10 2013 +0100 @@ -213,7 +213,6 @@ ( str.close (); true ) ), -//!!! is this what we want? zeros in subsequent channels? cross-check with channels module "mixedTo-2-3-\(name)": \( str = filt.mixedTo 3 (filt.multiplexed @@ -231,7 +230,6 @@ ( str.close (); true ) ), -//!!! is this what we want? zeros in subsequent channels? cross-check with channels module and behaviour of 1->2 mixing "mixedTo-1-3-\(name)": \( str = filt.mixedTo 3 (withDuration 3 (syn.generated 2 id)); compare str.position 0 and @@ -239,7 +237,7 @@ compare str.sampleRate 2 and compare str.available (maybeKnown 3) and compare str.finished? false and - compare (map bl.list (mat.asRows (str.read 4))) [[0,1,2],[0,0,0],[0,0,0]] and + compare (map bl.list (mat.asRows (str.read 4))) [[0,1,2],[0,1,2],[0,1,2]] and compare str.position 3 and compare str.available (Known 0) and compare str.finished? true and