;; read and display a WAV file.
;; Yann LeCun, October 2002.

(libload "audiofile/audiofile")

(de plot-wave (x y w off sx sy)
  (let ((lx x) (ly (+ y (* sy (- (w 0) off)))))
    (for (i 0 (1- (idx-dim w 0)))
	 (draw-line lx ly (+ x i) (+ y (* sy (- (w i) off))))
	 (setq lx (+ x i)) (setq ly (+ y (* sy (- (w i) off)))))))

(setq wave (audiofile-read 
	    (concat-fname lushdir "packages/audiofile/demos/space.wav")))

(for (k 0 (- (idx-dim wave 0) 500) 5)
     (graphics-batch
      (cls)
      (plot-wave 10 250 (narrow wave 0 500 k) 128 1 3)))
