;; this is a stereo cludge
(bind-func static reverb_st_c
(lambda ()
(let ((MILLIS (* .001 SRs))
(dly1_l (comb_c (* SR 4))) (dly1_delay (* 40.0 MILLIS)) (dly1_fb 0.0)
(dly1_r (comb_c (* SR 4)))
(lpf1_l (lpf_1p_c)) (lpf1_g 0.45)
(lpf1_r (lpf_1p_c))
(apf1_l (comb_apf_c (/ SR 4))) (apf1_delay (* 13.28 MILLIS)) (apf1_gain 0.7)
(apf1_r (comb_apf_c (/ SR 4)))
(apf2_l (comb_apf_c (/ SR 4))) (apf2_delay (* 28.13 MILLIS)) (apf2_gain -0.7)
(apf2_r (comb_apf_c (/ SR 4)))
(comb1 (comb_c (/ SR 4))) (comb1_delay (* 31.71 MILLIS)) (comb1_fb 0.0)
(comb2 (comb_c (/ SR 4))) (comb2_delay (* 37.11 MILLIS)) (comb2_fb 0.0)
(comb3 (comb_c (/ SR 4))) (comb3_delay (* 40.23 MILLIS)) (comb3_fb 0.0)
(comb4 (comb_c (/ SR 4))) (comb4_delay (* 44.14 MILLIS)) (comb4_fb 0.0)
(comb5 (comb_c (/ SR 4))) (comb5_delay (* 30.47 MILLIS)) (comb5_fb 0.0)
(comb6 (comb_c (/ SR 4))) (comb6_delay (* 33.98 MILLIS)) (comb6_fb 0.0)
(comb7 (comb_c (/ SR 4))) (comb7_delay (* 41.41 MILLIS)) (comb7_fb 0.0)
(comb8 (comb_c (/ SR 4))) (comb8_delay (* 42.58 MILLIS)) (comb8_fb 0.0)
(lpf2 (lpf_1p_c)) (lpf2_g 0.5)
(lpf3 (lpf_1p_c)) (lpf3_g 0.5)
(apf3 (comb_apf_c (* SR 1))) (apf3_delay (* 9.38 MILLIS)) (apf3_gain -0.6)
(apf4 (comb_apf_c (* SR 1))) (apf4_delay (* 11.0 MILLIS)) (apf4_gain 0.6)
(oldsize:SAMPLE 0.0)
(lout:SAMPLE 0.0)
(rout:SAMPLE 0.0)
(input 0.0)
(out:SAMPLE 0.0))
(lambda (chan:i64 x size predelay:SAMPLE absorb:SAMPLE mix)
(if (= chan 0)
(begin
(if (<> size oldsize)
(begin (set! oldsize size)
(set! size (* size 5000.0))
(set! comb1_fb (comb_fb_from_rtsixty size comb1_delay))
(set! comb2_fb (comb_fb_from_rtsixty size comb2_delay))
(set! comb3_fb (comb_fb_from_rtsixty size comb3_delay))
(set! comb4_fb (comb_fb_from_rtsixty size comb4_delay))
(set! comb5_fb (comb_fb_from_rtsixty size comb5_delay))
(set! comb6_fb (comb_fb_from_rtsixty size comb6_delay))
(set! comb7_fb (comb_fb_from_rtsixty size comb7_delay))
(set! comb8_fb (comb_fb_from_rtsixty size comb8_delay))))
(set! input x)
;; predelay
(set! dly1_delay (* predelay MILLIS))
(set! out (dly1_l input dly1_delay 0.5 0.5 0.0)) ;dly1_fb))
;; input diffusion
(set! out (lpf1_l out absorb))
(set! out (apf1_l out apf1_delay apf1_gain))
(set! out (apf2_l out apf2_delay apf2_gain))))
(if (= chan 1)
(begin
(set! input x)
(set! out (dly1_r input dly1_delay 0.5 0.5 0.0)) ;dly1_fb))
;; input diffusion
(set! out (lpf1_r out absorb))
(set! out (apf1_r out apf1_delay apf1_gain))
(set! out (apf2_r out apf2_delay apf2_gain))))
;; left channel
(if (= chan 0)
(begin
(set! lout (+ (* 0.15 (comb1 out comb1_delay 1.0 1.0 comb1_fb))
(* -0.15 (comb2 out comb2_delay 1.0 1.0 comb2_fb))
(* 0.15 (comb3 out comb3_delay 1.0 1.0 comb3_fb))
(* -0.15 (comb4 out comb4_delay 1.0 1.0 comb4_fb))))
(set! lout (lpf2 lout lpf2_g))
(set! lout (apf3 lout apf3_delay apf3_gain))))
;; right channel
(if (= chan 1)
(begin
(set! rout (+ (* 0.15 (comb5 out comb5_delay 1.0 1.0 comb5_fb))
(* -0.15 (comb6 out comb6_delay 1.0 1.0 comb6_fb))
(* 0.15 (comb7 out comb7_delay 1.0 1.0 comb7_fb))
(* -0.15 (comb8 out comb8_delay 1.0 1.0 comb8_fb))))
(set! rout (lpf3 rout lpf3_g))
(set! rout (apf4 rout apf4_delay apf4_gain))))
(if (= chan 0)
(* (+ 1.0 mix) (+ (* input (- 1.0 mix)) (* lout mix)))
(if (= chan 1)
(* (+ 1.0 mix) (+ (* input (- 1.0 mix)) (* rout mix)))
0.0))))))