(bind-func osc2_cc
(lambda ()
(let ((val 0.0:f)
(osc-octave 0)
(osc-tune 1.0)
(osc-octave-value 1.0))
(lambda (inst offset:i32 cc:i32 value:i32)
;; (println 'osc2_cc cc value)
(set! val (/ (i32tof value) 127.0))
(cond ((= cc (+ offset 0)) ;; amplitude of osc 1
(set_osc2_amp inst val))
((= cc (+ offset 1)) ;; waveform of osc 1 (PARAM_SINE,PARAM_SAW,PARAM_PULSE,PARAM_TRI,PARAM_WT)
(set_osc2_wave inst (get_waveform value)))
((= cc (+ offset 2)) ;; pulse width (for PARAM_PULSE wave) 0.0-1.0 (0.5 is square)
(set_osc2_pw inst val))
((= cc (+ offset 3)) ;; frequency shift of osc - tuning - 2.0 up
;; tune 0.5 down tune etc..
(set! osc-tune (+ 1.0 (+ -0.2 (* val 0.4))))
(set_osc2_tune inst (* osc-octave-value osc-tune)))
((= cc (+ offset 4))
(set! osc-octave (- (clamp value 61 70) 64))
(set! osc-octave-value (octave_from_val val))
(set_osc2_tune inst (* osc-octave-value osc-tune))
;; (println 'v osc2-octave 'v2 osc2-octave-value)
void)
((= cc (+ offset 5)) ;; phase (default is 0.0)
(set_osc2_phase inst val)))))))