(define *srate* 44100)
(definstrument (pulses start duration frequency 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 frequency)))
    (do ((counter start-sample (+ counter 1)))
        ((> counter end-sample))
          (outa counter (* (env amp-env) (pulse-train pulse))))))

(with-sound (:srate 44100 :output "pulses.aiff") (pulses 0 10 220 '(0 0 0.5 1 1 0)))
