Mercurial > hg > may
changeset 355:25eca2005685
Average when mixing down, don't sum
author | Chris Cannam |
---|---|
date | Tue, 25 Jun 2013 09:15:18 +0100 |
parents | 9632dc4432af |
children | 5fe32d3c2dd7 |
files | may/stream/channels.yeti may/stream/test/test_channels.yeti may/stream/test/test_filter.yeti |
diffstat | 3 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/may/stream/channels.yeti Tue Jun 25 09:15:10 2013 +0100 +++ b/may/stream/channels.yeti Tue Jun 25 09:15:18 2013 +0100 @@ -43,14 +43,14 @@ mat.newMatrix (RowMajor ()) (map vec.vector vv); fi; -mixedDown m = //!!! sum or average? at the moment we sum +mixedDown m = //!!!doc: average, not sum ({ columns, rows } = (mat.size m); if rows < 1 or columns < 1 then vec.zeros 0 elif rows == 1 then mat.getRow 0 m else - bf.add (mat.asRows m); + bf.divideBy rows (bf.add (mat.asRows m)); fi); mixedDownFromInterleaved channels b = @@ -65,7 +65,7 @@ v'[col] := v'[col] + v[col * channels + row]; done; done; - vec.vector v'; + bf.divideBy channels (vec.vector v'); fi; mixedFromInterleavedTo targetChannels channels b =
--- a/may/stream/test/test_channels.yeti Tue Jun 25 09:15:10 2013 +0100 +++ b/may/stream/test/test_channels.yeti Tue Jun 25 09:15:18 2013 +0100 @@ -30,21 +30,21 @@ "mixedDown": \( compareBlocks (ch.mixedDown (newMatrix [[1,4],[2,5],[3,6]])) - (vec.fromList [5,7,9]) and + (vec.fromList [5/2,7/2,9/2]) and compareBlocks (ch.mixedDown (newMatrix [])) (vec.fromList []) ), "mixedDownFromInterleaved": \( compareBlocks (ch.mixedDownFromInterleaved 2 (vec.fromList [1,4,2,5,3,6])) - (vec.fromList [5,7,9]) and + (vec.fromList [5/2,7/2,9/2]) and compareBlocks (ch.mixedDownFromInterleaved 1 (vec.fromList [1,2,3])) (vec.fromList [1,2,3]) ), "mixedFromInterleavedTo": \( compareBlocks (ch.mixedFromInterleavedTo 1 2 (vec.fromList [1,4,2,5,3,6])) - (vec.fromList [5,7,9]) and + (vec.fromList [5/2,7/2,9/2]) and compareBlocks (ch.mixedFromInterleavedTo 2 2 (vec.fromList [1,4,2,5,3,6])) (vec.fromList [1,4,2,5,3,6]) and compareBlocks (ch.mixedFromInterleavedTo 3 2 (vec.fromList [1,4,2,5,3,6])) @@ -59,7 +59,7 @@ "mixedAndInterleavedTo": \( compareBlocks (ch.mixedAndInterleavedTo 1 (newMatrix [[1,4],[2,5],[3,6]])) - (vec.fromList [5,7,9]) and + (vec.fromList [5/2,7/2,9/2]) and compareBlocks (ch.mixedAndInterleavedTo 2 (newMatrix [[1,4],[2,5],[3,6]])) (vec.fromList [1,4,2,5,3,6]) and compareBlocks (ch.mixedAndInterleavedTo 3 (newMatrix [[1,4],[2,5],[3,6]]))
--- a/may/stream/test/test_filter.yeti Tue Jun 25 09:15:10 2013 +0100 +++ b/may/stream/test/test_filter.yeti Tue Jun 25 09:15:18 2013 +0100 @@ -260,7 +260,7 @@ compare str.sampleRate 2 and compare str.available (maybeKnown 3) and compare str.finished? false and - compare (map vec.list (mat.asRows (str.read 4))) [[0,2,4]] and + compare (map vec.list (mat.asRows (str.read 4))) [[0,1,2]] and compare str.position 3 and compare str.available (Known 0) and compare str.finished? true and