;; --- N Sample BLEP (uPointsPerSide = N)
(bind-func static blep_n
(lambda (table:SAMPLE* tablelen:SAMPLE mod:SAMPLE inc:SAMPLE height:SAMPLE rising:i1 num_points:SAMPLE interp:i1)
(let ((blep 0.0) (t 0.0) (table_centre (- (/ tablelen 2.0) 1.0))
(doright:i1 1) (frac 0.0)
(i:i64 1) (idx 0.0))
;; left side
(while (<= i (convert num_points))
(if (> mod (- 1.0 (* (convert i) inc)))
(begin
;; calc distance
(set! t (/ (- mod 1.0) (* num_points inc)))
;; get index
(set! idx (* (+ 1.0 t) table_centre))
;; truncate
(if (not interp)
(begin
(set! blep (pref table (convert idx i64)))
void)
(begin
(set! frac (- idx (convert (convert idx i64))))
(set! blep (LinTerp 0.0 1.0
(pref table (convert idx i64))
(pref table (convert (+ idx 1.0) i64))
frac))
void))