# HG changeset patch # User Chris Cannam # Date 1370018086 -3600 # Node ID f099fb3c63a0135422dd85cdecc92d5652051fe1 # Parent 9bc985b602b3838071ee6f8706aef739219c5f0c Make a start on fast convolver diff -r 9bc985b602b3 -r f099fb3c63a0 yetilab/stream/filter.yeti --- a/yetilab/stream/filter.yeti Fri May 31 17:34:37 2013 +0100 +++ b/yetilab/stream/filter.yeti Fri May 31 17:34:46 2013 +0100 @@ -4,6 +4,10 @@ mat = load yetilab.matrix; ch = load yetilab.stream.channels; vec = load yetilab.vector; +fr = load yetilab.stream.framer; +win = load yetilab.signal.window; +fft = load yetilab.transform.fft; +syn = load yetilab.stream.syntheticstream; load yetilab.stream.type; load yetilab.vector.type; @@ -263,6 +267,21 @@ done [1..copies]; fi; +zeroPaddedFreqFrames framesize stream = +//!!! mono only for now + (f = fft.realForward framesize; + map f + (map (vec.resizedTo (2 * framesize)) + (fr.windowedFrames + { framesize, hop = framesize, window = win.boxcar } + stream))); + +fastConvolvedWith ir framesize s = + (irfr = zeroPaddedFreqFrames framesize (syn.precalculated (s.sampleRate) ir); + sigfr = zeroPaddedFreqFrames framesize s; + s + ); + convolvedWith ir s = (if mat.height ir != s.channels then failWith "Signal stream and IR must have same number of channels (\(s.channels) != \(mat.height ir))"