;;; -*- Lisp
;;;
;;;

(definstrument bird (start-time duration frequency freq-skew amplitude Freq-envelope Amp-envelope 
	             &optional (lpfilt 1.0) (degree 0) (reverb-amount 0))
  (multiple-value-bind (beg end) (get-beg-end start-time duration)
    (let* ((amp-env (make-env :envelope amp-envelope :scaler amplitude :start-time start-time :duration duration))
	   (gls-env (make-env :envelope freq-envelope :scaler (in-Hz freq-skew) :start-time start-time :duration duration))
	   (loc (make-locsig :degree degree :distance 1.0 :revscale reverb-amount))
	   (fil (make-one-pole lpfilt (- 1.0 lpfilt)))
	   (s (make-oscil :frequency frequency)))
      (Run
       (loop for i from beg to end do
	 (locsig loc i (one-pole fil (* (env amp-env) (oscil s (env gls-env))))))))))

