view src/scheme/filter.scm @ 1:5df24c91468d

Oh my what a mess.
author samer
date Fri, 05 Apr 2019 16:26:00 +0100
parents bf79fb79ee13
children
line wrap: on
line source
(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 )))))))