(bind-func cerberus_lfo4_cc
(lambda ()
(let ((val 0.0:f)
(amp 1.0)
(frq 1.0)
(options 0)
(phase 0.0)
(envlgth 2.0)
(lfoenv (vector_ref 10.0:f 10.0 0.0 0.0)))
(lambda (inst offset:i32 cc:i32 value:i32)
;; (println 'cerberus_lfo4_cc cc value)
(set! val (/ (i32tof value) 127.0))
(cond ((= cc (+ offset 0)) ;; env attack
(vset! lfoenv 0 (* val 1000.0))
(set_lfo_ad inst PARAM_LFO4 (* envlgth (vref lfoenv 0)) (* envlgth (vref lfoenv 1)) (vref lfoenv 2) (vref lfoenv 3)))
((= cc (+ offset 1)) ;; env decay
(vset! lfoenv 1 (* val 1000.0))
(set_lfo_ad inst PARAM_LFO4 (* envlgth (vref lfoenv 0)) (* envlgth (vref lfoenv 1)) (vref lfoenv 2) (vref lfoenv 3)))
((= cc (+ offset 2)) ;; env attack slope
(vset! lfoenv 2 (- (* val 2.0) 1.0))
(set_lfo_ad inst PARAM_LFO4 (* envlgth (vref lfoenv 0)) (* envlgth (vref lfoenv 1)) (vref lfoenv 2) (vref lfoenv 3)))
((= cc (+ offset 3)) ;; env decay slope
(vset! lfoenv 3 (- (* val 2.0) 1.0))
(set_lfo_ad inst PARAM_LFO4 (* envlgth (vref lfoenv 0)) (* envlgth (vref lfoenv 1)) (vref lfoenv 2) (vref lfoenv 3)))
((= cc (+ offset 4)) ;; env length
(set! envlgth (* val 8.0))
(set_lfo inst PARAM_LFO4 amp (* envlgth frq) phase options)
(set_lfo_ad inst PARAM_LFO4 (* envlgth (vref lfoenv 0)) (* envlgth (vref lfoenv 1)) (vref lfoenv 2) (vref lfoenv 3)))
((= cc (+ offset 5)) ;; lfo amp
(set! amp val)
(set_lfo inst PARAM_LFO4 amp frq phase options))
((= cc (+ offset 6)) ;; lfo frq
(set! frq (clamp (* val 10.0) 0.05 20.0))
(set_lfo inst PARAM_LFO4 amp (* envlgth frq) phase options))
((= cc (+ offset 7)) ;; lfo type
(set_lfo_type inst PARAM_LFO4 (cerberus_get_lfo_waveform value))))))))