Mercurial > hg > may
diff yetilab/stream/framer.yeti @ 285:be39f21456a1
More on overlap-add for frames
author | Chris Cannam |
---|---|
date | Thu, 30 May 2013 17:34:35 +0100 |
parents | 7932bbb7bacb |
children | 6ed6af2fc794 |
line wrap: on
line diff
--- a/yetilab/stream/framer.yeti Wed May 29 22:59:23 2013 +0100 +++ b/yetilab/stream/framer.yeti Thu May 30 17:34:35 2013 +0100 @@ -94,11 +94,25 @@ close = \(), }); +overlapAdd channels framesize hop frames = + (ola fr acc = + if empty? fr then + [acc] + else + 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; + fi; + mat.concat (Horizontal ()) (ola frames (mat.zeroSizeMatrix ()))); + streamOverlapping rate framesize hop frames = (var remaining = frames; var buffered = mat.zeroSizeMatrix (); var position = 0; - w = win.hann framesize; + w = win.windowFunction (Hann ()) [ Symmetric true ] framesize; channels = mat.height (head frames); // so we don't need to keep a head ptr filt.delayedBy (- (framesize - hop)) { @@ -125,7 +139,9 @@ remaining := tail remaining; framesFor (samples - hop) (acc ++ [this]) fi; - source = mat.concat (Horizontal ()) (framesFor count [buffered]); + source = overlapAdd channels framesize hop + (framesFor count [buffered]); +// println "source = \(source)"; toReturn = mat.columnSlice source 0 count; buffered := mat.columnSlice source count (mat.width source); toReturn), @@ -169,6 +185,8 @@ frequencyDomainFramesOfFile parameters filename = frequencyDomainFrames parameters (af.open filename), + overlapAdd, + streamed, }