;; convolve.sal - use convolve to build a reverb and apply it

load "mateos/organ.lsp" ;; defines dmhm-organ(pitch)

function response()
  return noise() * pwev(0.5, 1, 0.001)

function melody()
  return sim(dmhm-organ(c4) ~ 0.5 @ 0,
             dmhm-organ(bf3) ~ 0.4 @ 0.4,
             dmhm-organ(f3) ~ 0.5 @ 0.8,
             dmhm-organ(g4) ~ 1 @ 1.3)

function convolve-demo-1()
  play convolve(melody(), response() ~ 4)

exec convolve-demo-1()

;; convolve audio ("happy birthday" song) with speech

function convolve-demo-2()
  play convolve(s-read("../audio/happy.wav"), 
                s-read("../audio/pv.wav"))

exec convolve-demo-2()
