Mercurial > hg > jslab
diff src/scheme/filter.scm @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/scheme/filter.scm Tue Jan 17 17:50:20 2012 +0000 @@ -0,0 +1,32 @@ +(define (hp x) + ; Normaliser used as high pass filter to remove slow variations + (define n (node "phase1" (NormaliseVector. x))) + (addtasks n) + (.output n) +) + +(define (lp x) + ; Normaliser used as low pass filter to remove fast variations + (define n (node "lp" (NormaliseVector. x))) + (addtasks n) + (.mean n) +) + +(define (bp x) (lp (hp x))) + + +(define (smooth-signal sig) (addtask + (node (.getNode sig) + (GenerateDouble. (VDouble. "smoothed") + (FilteredGenerator. (DoubleGenerator. sig) + (IIRFilter. + ; two element double array controlled by VDouble + (let ((a (double[] #(1 0))) + (p (samer.core.types.VDouble. "smoothness" 1.0))) + (on-change p + (let ((r (Math.exp (- (.get p))))) + (double[] a 0 r) + (double[] a 1 (- 1 r)))) + (.changed p) + a ))))))) +