;;; -*- syntax: Lisp; font-size: 16; line-numbers: no; -*-
(define *srate* 44100)

(definstrument (soundfile-envs 
	       start-time duration soundfile amplitude-envelope srate-envelope)
  (let* ((start-sample (* start-time *srate*))
         (end-sample (+ start-sample (* duration *srate*)))
         (sf (make-readin soundfile))
         (wavetable (make-src sf))
         (amp-env (make-env :duration duration 
                            :envelope amplitude-envelope))
         (srate-env (make-env :duration duration
                              :envelope srate-envelope)))
(do ((sample-number start-sample (+ sample-number 1)))
        ((= sample-number end-sample))
 (outa sample-number (* (env amp-env)
                                 (src wavetable (env srate-env)))))))

(with-sound (:srate 44100) 
  (soundfile-envs 0 4 "/Users/danielhensel/1-4.wav"  '(0 0 0.1 1 0.9 1 1 0) '(0 1 1 0.2)))
|#
