;;; ;;; Simple demonstration of two pole filter ;;; nando, October 28 1996 ;;; (defmacro b1-from-r-freq (r freq) `(- (* 2.0 ,r (cos (hz->radians ,freq))))) (defmacro b2-from-r (r) `(* ,r ,r)) (definstrument twopole(start-time duration amplitude &key (freq '(0 20 1 10000)) (r '(0 0.5 1 0.5))) (multiple-value-bind (beg end) (times->samples start-time duration) (let* ((noise (make-rand :frequency (* 0.49 *srate*) :amplitude amplitude)) (freq-env (make-env :envelope freq :duration duration)) (r-env (make-env :envelope r :duration duration)) (ppfilt (make-ppolar :r 0.5 :frequency 440.0))) (run (loop for i from beg to end do (let* ((freq0 (env freq-env)) (r0 (env r-env))) (setf (mus-b1 ppfilt) (b1-from-r-freq r0 freq0)) (setf (mus-b2 ppfilt) (b2-from-r r0)) (outa i (two-pole ppfilt (rand noise))))))))) ;;; Frequency sweep, no resonance (r=0.3...0.5...0.7) ;;; (with-sound()(twopole 0 5 0.01 :r '(0 0.3 1 0.3) :freq '(0 10 0.1 10 0.9 10000 1 10000))) ;;; (with-sound()(twopole 0 5 0.01 :r '(0 0.5 1 0.5) :freq '(0 10 0.1 10 0.9 10000 1 10000))) ;;; Fixed frequency, resonance sweep ;;; (with-sound()(twopole 0 5 0.001 :r '(0 0.1 0.1 0.1 0.9 0.9999 1 0.9999) :freq '(0 440 1 440)))