;; convolve with extract-abs from some sound

variable *plightpath* = strcat(current-path(), "../lib/plight/")

define function ex50()
  begin
    with idur = 5000,
         fill1 = to-mono(s-read(strcat(*plightpath*, "fill-1.wav"))),
         crash = to-mono(s-read(strcat(*plightpath*, "16-crash-4.wav"))),
         s-array = snd-fetch-array(crash, idur, idur),
         impulse = snd-from-array(0, *sound-srate*, s-array)
    print "PLAYING EX50 IMPULSE:"
    play impulse
    print "PLAYING EX50 CONVOLUTION:"
    play 0.05 * convolve(fill1, impulse)
  end

exec trace(snd-xform)

define function ex51()
  begin
    with idur = 5000,
         fill1 = to-mono(s-read(strcat(*plightpath*, "fill-1.wav"))),
         crash = to-mono(s-read(strcat(*plightpath*, "16-crash-4.wav"))),
         impulse = extract-abs(0, idur / *sound-srate*, crash)
    print "PLAYING EX51 IMPULSE:"
    play impulse
    print "PLAYING EX51 CONVOLUTION"
    play 0.05 * convolve(fill1, impulse)
  end    

exec ex50()
exec ex51()
