[CM] hilbert transformer and other FIR filter stuff

Bill Schottstaedt bil@ccrma.Stanford.EDU
Tue, 7 Jan 2003 02:51:36 -0800


Speaking of the CLM Hilbert transformer -- the code looks
broken to me -- I think a crucial line got lost at some
point.  Just for lafs I conjured up this Scheme version:

(define* (make-hilbert-transform #:optional (len 30))
  (let* ((arrlen (1+ (* 2 len)))
	 (arr (make-vct arrlen)))
    (do ((i (- len) (1+ i)))
	((= i len))
      (let* ((k (+ i len))
	     (denom (* pi i))
	     (num (- 1.0 (cos (* pi i)))))
	(if (= i 0)
	    (vct-set! arr k 0.0)
	    (vct-set! arr k (/ num denom)))))
    (make-fir-filter arrlen arr)))

(define (hilbert-transform f in)
  (fir-filter f in))

#!
  (let ((h (make-hilbert-transform 15)))
    (map-channel (lambda (y)
		   (* 8.0 (hilbert-transform h y)))))
!#

I'll replace the CLM version with a translation
of this code.  As long as I was typing in FIR filter
code, I figured I might as well add lowpass, highpass,
bandstop, bandpass, and differentiators of any order --
see dsp.scm.