Mercurial > hg > may
diff yetilab/stream/framer.yeti @ 290:21ec05237c1a
Revise overlap-add
author | Chris Cannam |
---|---|
date | Fri, 31 May 2013 10:58:00 +0100 |
parents | b34960d2b519 |
children | c40821ff70f8 |
line wrap: on
line diff
--- a/yetilab/stream/framer.yeti Thu May 30 22:33:16 2013 +0100 +++ b/yetilab/stream/framer.yeti Fri May 31 10:58:00 2013 +0100 @@ -94,17 +94,24 @@ close = \(), }); -overlapAdd channels framesize hop frames = +overlapAdd channels overlap frames = (ola fr acc = if empty? fr then [acc] else + pre = mat.columnSlice acc 0 (mat.width acc - overlap); + added = mat.sum (head fr) + (mat.resizedTo { columns = mat.width (head fr), rows = channels } + (mat.columnSlice acc (mat.width acc - overlap) (mat.width acc))); + /* frameSized = mat.resizedTo { columns = framesize, rows = channels }; extended = frameSized (mat.columnSlice acc hop (mat.width acc)); added = mat.sum (frameSized (head fr)) extended; (mat.columnSlice acc 0 hop) :: ola (tail fr) added; +*/ + pre :: ola (tail fr) added; fi; mat.concat (Horizontal ()) (ola frames (mat.zeroSizeMatrix ()))); @@ -113,7 +120,8 @@ var buffered = mat.zeroSizeMatrix (); var position = 0; factor = hop / (framesize/2); - w = bf.scaled factor (win.hann framesize); + w = bf.scaled factor (win.hann framesize); // periodic window, not symmetric + println "window is \(vec.list w)"; channels = mat.height (head frames); // so we don't need to keep a head ptr filt.delayedBy (- framesize) { @@ -127,16 +135,22 @@ if samples <= 0 or empty? remaining then acc else - this = mat.newMatrix (RowMajor ()) - (map (bf.multiply w) (mat.asRows (head remaining))); + println "multiplying \(head remaining) by window"; + this = mat.resizedTo + { columns = framesize, rows = channels } + (mat.newMatrix (RowMajor ()) + (map (bf.multiply w) + (mat.asRows (head remaining)))); remaining := tail remaining; framesFor (samples - hop) (acc ++ [this]) fi; - source = overlapAdd channels framesize hop + source = overlapAdd channels (framesize - hop) (framesFor count [buffered]); toReturn = mat.columnSlice source 0 count; position := position + mat.width toReturn; buffered := mat.columnSlice source count (mat.width source); + println "count = \(count), framesize = \(framesize), hop = \(hop)"; + println "leaving position = \(position), buffered = \(buffered), returning \(toReturn)"; toReturn), close = \(), });