;;; -*- syntax: Lisp; font-size: 16; line-numbers: no; -*-

(define *srate* 44100)
(definstrument (sine-freq-env start-time duration frequency-envelope amplitude-envelope)
  (let* ((start-sample (* start-time *srate*))
         (end-sample (+ start-sample (* duration *srate*)))
         (oscillator (make-oscil :frequency 0.0))
         (freq-env (make-env :envelope frequency-envelope
                             :scaler (hz->radians 1)
                             :duration duration))
         (amp-env (make-env :envelope amplitude-envelope
                            :duration duration)))
     (do ((index start-sample (+ index 1)))
         ((> index end-sample))
          (outa index (* (env amp-env) (oscil oscillator (env freq-env)))))))

; sine with glissando
(with-sound (:srate 44100) (sine-freq-env 0 5 '(0 0 .25 880 .5 220 1 1720) '(0 0 0.1 1 0.8 1 1 0))) 

