(define *srate* 44100)

(definstrument (soundfile-locsig start-time duration soundfile &key
					     (start 0)
					     (pan 45)
					     (amplitude-envelope '(0 0 .1 1 .9 1 1 0))
					     (srt 1)
					     (srate-envelope '(0 1 1 1)))
  (let* ((start-sample (* start-time *srate*))
         (end-sample (+ start-sample (* duration *srate*)))
	 
(input-start (* *srate* start))      
       	  (f (make-readin soundfile :start input-start))
	 (wavetable (make-src :input f :srate 0.0)) 
	 (loc (make-locsig :degree pan :distance 1)) 
         (amp-env (make-env :duration duration 
                            :envelope amplitude-envelope))
         (srate-env (make-env :duration duration
                              :envelope srate-envelope
			      :scaler srt)))
     (do ((sample-number start-sample (+ sample-number 1)))
        ((= sample-number end-sample))
          (locsig loc sample-number (* (env amp-env)
                                 (src wavetable (env srate-env)))))))

#|
(with-sound (:srate 44100 :channels 2 :output "playback-locsig.aiff")
  (soundfile-locsig 0 3.5 "/Users/danielhensel/1-4.wav" :pan 90))
|#