;;
;; native convolution
;;
;; this assumes mono IR file
;;
;; lgth is size of IR in frames
;; anything bigger than 1/4 of a second is
;; going to make extempore work very hard
;;
;; N should be 2's compliment
(bind-func convolution_c
(lambda (filename N:i64)
(let ((ir:SAMPLE* (zalloc N))
(total 0.0) (i 0) (n 0) (N1 (- N 1))
(input:SAMPLE* (zalloc N)))
(sf_read_file_into_buffer filename ir 0 N #f)
(lambda (in dry:SAMPLE wet:SAMPLE)
(pset! input n in)
(set! total 0.0)
(dotimes (i N)
(set! total
(+ total
(* (pref ir i)
(pref input (& (- n i) N1))))))
(set! n (& (+ n 1) N1))
(+ (* dry in) (* wet total))))))