
;;;   original instrument was written by Christopher Burns

(define *srate* 44100)
(definstrument (filtered-pulses start duration pulse-frequency center-frequency q amplitude-envelope)
  (let* ((start-sample (* start *srate*))
         (end-sample (+ start-sample (* duration *srate*)))
         (amp-env (make-env :duration duration
                            :envelope amplitude-envelope))
         (pulse (make-pulse-train :frequency pulse-frequency))
         (resonator (make-formant :frequency center-frequency
                                  :radius q)))
    (do ((counter start-sample (+ counter 1)))
    ((>= counter end-sample))
          (outa counter (* (env amp-env) (formant resonator (pulse-train pulse)))))))

#|
(with-sound (:srate 44100 :statistics #t) 
  (filtered-pulses 0 7 220 440 .8 '(0 0 0.5 1 1 0)))
|#