;nyquist plug-in
;version 1
;type process
;categories "http://lv2plug.in/ns/lv2core#ModulatorPlugin"
;name "SinIsoMod..."
;action "Modulating..."
;info "Sine Isochronic Modulator. Encode by Steve Daulton. GPL v.2\nhttp://easyspacepro.com\n\nTerminated by Carlos H. Ramírez G.\n"

;control startf "Initial Modulation Frequency" real "Hz" 7 0.1 40
;control endf "Final Modulation Frequency" real "Hz" 14 0.1 40
;control starta "Initial Modulation Depth" int "%" 100 0 100
;control enda "Final Modulation Depth" int "%" 100 0 100



   (setq duration 0.5)
   
   (abs-env
   (progn
   ;; half sine wave
   ;(setq si (abs-env (osc (hz-to-step 1.0) duration *sine-table* 0)))

   ;; full sine wave
   (setq si (mult 0.5 (sum 1 (osc (hz-to-step 2.0) duration *sine-table* 270))))

   ;; add silence
   (setq pulse (sim si (s-rest 1)))

   ;; create wavetable
   (setq *waveform* (list pulse (hz-to-step 1) T))))
   
   ; test it
   ;(osc 69 1 *waveform*)
   (mult s (fmlfo (pwlv 20 1.0 10) *waveform*))   

;; Function to generate sweep tone
(defun sweep (sf ef)
     (mult 0.5 (sum 1.0 (fmlfo (pwlv sf 1.0 ef) *waveform*))))

(let* ((starta (/ starta 50.0))
   (enda (/ enda 50.0))
   (wet (pwlv starta 1 enda))
   (dry (sum 1 (mult wet -1))))
   (mult s (sum dry (mult wet (sweep startf endf)))))
