changeset 295:f099fb3c63a0

Make a start on fast convolver
author Chris Cannam
date Fri, 31 May 2013 17:34:46 +0100
parents 9bc985b602b3
children ec6a36d88f57
files yetilab/stream/filter.yeti
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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))"