changeset 374:4ca19c9819b8

Fix factor of two error in cutoff frequency (first basic unit test for lowpass now passes)
author Chris Cannam
date Wed, 31 Jul 2013 18:18:03 +0100
parents a1679a2b631c
children 1020b77a952d
files may/stream/filter.yeti
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/may/stream/filter.yeti	Wed Jul 31 14:28:30 2013 +0100
+++ b/may/stream/filter.yeti	Wed Jul 31 18:18:03 2013 +0100
@@ -437,9 +437,10 @@
    (rate = s.sampleRate;
     kw = win.kaiserForBandwidth attenuation bandwidth rate;
     filterLength = vec.length kw;
+    // First arg to sinc is the complete cycle length for the cutoff frequency
     idealFor freq =
-        bf.scaled (freq / rate)
-           (win.sinc ((rate / freq) * 2) filterLength);
+        bf.scaled (2 * freq / rate)
+           (win.sinc (rate / freq) filterLength);
     idealBandpass =
          if f1 < rate/2 then
              if f0 > 0 then bf.subtract (idealFor f1) (idealFor f0)