;nyquist plug-in
;version 1
;type generate
;name "Tremolo Sweep"
;action "Generating Sound..."
;info "Tremolo Sweep v.0.1 by Steve Daulton\nhttp://audacity.easyspacepro.com\n\nBased on code by Dominic Mazzoni, David R. Sky, Adam Pope and Paul Schimmel.\nReleased under terms of the GPL version 2.\nWarning. This is version 0.1 and there are no checks on the input data."

;control startf "Start Frequency" real "Hz" 880 20 20000
;control endf "End Frequency" real "Hz" 440 20 20000
;control dur "Duration" real "Seconds" 10 1 300
;control level "Level" real " (0 to 1)" 0.8 0 1
;control type "Sweep scale" int "[1=Linear, 2=Exponential]" 2 1 2
;control mix "Tremolo Wetness level" int "%" 40 0 100
;control lfo "Tremolo Frequency" real "Hz" 4.0 0.1 400.0

;; Function to generate sweep tone
(defun sweep (sf ef d lev m)
   (if (= m 2)
      (scale lev (fmosc 0 (pwev sf d ef)))
      (scale lev (fmosc 0 (pwlv sf d ef)))))

; Tremolo function
(defun tremolo (s-in wet freq)
(let*
   ((wet (/ wet 200.0))
   (mod-s (osc (hz-to-step lfo) dur *sine-table*)) ; the modulation signal
   (dry-s (const (- 1.0 wet) dur)) ; dry component
   (mod-s (scale wet mod-s)) ; scaled mod signal
   (mod-s (sum dry-s mod-s))) ; mixed mod signal
   (mult s-in mod-s)))

(tremolo (sweep startf endf dur level type) mix lfo) ;apply tremolo function to sweep function