; Arvel Hernandez
; ===============

(define filterecho
      (lambda* (secs samps bz #&optional (att 1.0))
            (let ((echodel (make-delay (round (* secs (srate)))))
                       (filtdel (make-delay samps))
                       (yz 0.0)
                       (yy 0.0)
                       (yx 0.0)
                       (y0 0.0)
                       (a0 0.5))
              (lambda (x0)
                       (set! yz (tap echodel))
                       (set! yx (+ x0 (* att yz)))
                       (set! yy (tap filtdel))
                       (set! y0 (- (* a0 yx) (* bz yy)))
                       (delay echodel y0)
                       (delay filtdel yx)           ; feed into delayline
                       y0)
)))

; Call to simulate stringed instrument.
; Make on file containing the impulse response of the body.
(map-chan (filterecho 0.00061 1 -0.5 0.98))