;; tap delay
(bind-func static tap_delay_c
(lambda (max_delay num_of_taps)
(let ((line:SAMPLE* (zalloc max_delay))
(taps:i64* (zalloc num_of_taps))
(delay max_delay)
(time 0))
(lambda (x:SAMPLE)
(let ((y 0.0)
(i 0)
(n (modulo time delay))
(gain (/ 1.0 (convert num_of_taps))))
(pset! line n x)
(dotimes (i num_of_taps)
(set! y (+ y (* gain (pref line (% (+ (pref taps i) n) delay))))))
(set! time (+ time 1))
y)))))