(FILECREATED "17-Jul-84 14:00:54" {ERIS}<SPEECH>ROACH>WDISPLAY.FPKG;4 9683   

      changes to:  (FNS WDISPLAY.CREATEW WDISPLAY.SCALEX WDISPLAY.WAVE WDISPLAY.WAVE1 
			WDISPLAY.REPAINTFN WDISPLAY.DRAWXY WDISPLAY.CLEARW WDISPLAY.DRAWXAXIS 
			WDISPLAY.DRAWTIMEAXIS WDISPLAY.BUTTONEVENTFN WDISPLAY.LEFTBUTTONFN))


(* Copyright (c)  by NIL. All rights reserved.)

(PRETTYCOMPRINT WDISPLAYCOMS)

(RPAQQ WDISPLAYCOMS ((INITVARS (WDISPLAY.TIMEAXIS 15)
			       (WDISPLAY.YM128 (ADD1 WDISPLAY.TIMEAXIS))
			       (WDISPLAY.Y0 (IPLUS WDISPLAY.YM128 128))
			       (WDISPLAY.Y127 (IPLUS WDISPLAY.Y0 127))
			       (WDISPLAY.WIDTH 700)
			       (WDISPLAY.WINDOW NIL))
		     (FNS WDISPLAY.CREATEW WDISPLAY.SCALEX WDISPLAY.WAVE WDISPLAY.WAVE1 
			  WDISPLAY.REPAINTFN WDISPLAY.DRAWXY WDISPLAY.CLEARW WDISPLAY.DRAWXAXIS 
			  WDISPLAY.DRAWTIMEAXIS WDISPLAY.BUTTONEVENTFN WDISPLAY.LEFTBUTTONFN)
		     (P (MOVD 'WDISPLAY.WAVE 'SD)
			(MOVD 'WDISPLAY.WAVE1 'SD1))))

(RPAQ? WDISPLAY.TIMEAXIS 15)

(RPAQ? WDISPLAY.YM128 (ADD1 WDISPLAY.TIMEAXIS))

(RPAQ? WDISPLAY.Y0 (IPLUS WDISPLAY.YM128 128))

(RPAQ? WDISPLAY.Y127 (IPLUS WDISPLAY.Y0 127))

(RPAQ? WDISPLAY.WIDTH 700)

(RPAQ? WDISPLAY.WINDOW NIL)
(DEFINEQ

(WDISPLAY.CREATEW
  (LAMBDA (TITLE)                                            (* kbr: "17-Jul-84 14:00")
                                                             (* Manufacture blank window suitable for displaying 
							     waves *)
    (PROG (HEIGHT WIDTH REGION EXTENT WINDOW)
          (SETQ HEIGHT (HEIGHTIFWINDOW WDISPLAY.Y127 T))
          (SETQ WIDTH (WIDTHIFWINDOW WDISPLAY.WIDTH))
          (SETQ REGION (GETBOXREGION WIDTH HEIGHT NIL NIL NIL "Position Display Window"))
          (SETQ WINDOW (CREATEW REGION TITLE))
          (SETQ EXTENT (CREATE REGION
			       LEFT ← 0
			       BOTTOM ← 0
			       WIDTH ← WDISPLAY.WIDTH
			       HEIGHT ← HEIGHT))
          (WINDOWPROP WINDOW 'EXTENT EXTENT)
          (WINDOWPROP WINDOW 'REPAINTFN 'WDISPLAY.REPAINTFN)
          (WINDOWPROP WINDOW 'SCROLLFN 'SCROLLBYREPAINTFN)
          (WINDOWPROP WINDOW 'BUTTONEVENTFN 'WDISPLAY.BUTTONEVENTFN)
          (WINDOWPROP WINDOW 'SCALEX 1)
          (RETURN WINDOW))))

(WDISPLAY.SCALEX
  (LAMBDA (WINDOW SCALEX)                                    (* kbr: "17-Jul-84 14:00")
    (PROG NIL
          (WINDOWPROP WINDOW 'SCALEX SCALEX))))

(WDISPLAY.WAVE
  (LAMBDA (WAVE WINDOW)                                      (* kbr: "17-Jul-84 14:00")
                                                             (* Display array or file WAVE in WINDOW.
							     Default window to WDISPLAY.WINDOW *)
    (PROG NIL
          (COND
	    ((NULL WINDOW)
	      (COND
		((NULL WDISPLAY.WINDOW)
		  (SETQ WDISPLAY.WINDOW (WDISPLAY.CREATEW WAVE))))
	      (SETQ WINDOW WDISPLAY.WINDOW)))
          (WDISPLAY.WAVE1 WAVE WINDOW))))

(WDISPLAY.WAVE1
  (LAMBDA (WAVE WINDOW)                                      (* kbr: "17-Jul-84 14:00")
                                                             (* Display array or file WAVE in WINDOW *)
    (PROG (WIDTH EXTENT CLIPPINGREGION)
          (COND
	    ((NULL WINDOW)
	      (SETQ WINDOW (WDISPLAY.CREATEW WAVE))))
          (COND
	    ((ARRAYP WAVE)                                   (* WAVE is an array *)
	      (SETQ WIDTH (ARRAYSIZE WAVE)))
	    ((LITATOM WAVE)                                  (* WAVE is a file *)
	      (SETQ WAVE (FULLNAME WAVE))
	      (SETQ WIDTH (GETFILEINFO WAVE 'LENGTH))))
          (COND
	    ((WINDOWPROP WINDOW 'WAVE)                       (* Erase previous WAVE. Note: Must do DSPRESET before 
							     other DSP operations. *)
	      (DSPRESET WINDOW)
	      (DSPXOFFSET (IPLUS (fetch (REGION LEFT) of (WINDOWPROP WINDOW 'REGION))
				 (WINDOWPROP WINDOW 'BORDER))
			  WINDOW)
	      (SETQ CLIPPINGREGION (CREATE REGION
					   LEFT ← 0
					   BOTTOM ← 0
					   WIDTH ← (WINDOWPROP WINDOW 'WIDTH)
					   HEIGHT ← (WINDOWPROP WINDOW 'HEIGHT)))
	      (DSPCLIPPINGREGION CLIPPINGREGION WINDOW)))
          (WINDOWPROP WINDOW 'WAVE WAVE)
          (WINDOWPROP WINDOW 'TITLE WAVE)
          (SETQ EXTENT (CREATE REGION
			       LEFT ← 0
			       BOTTOM ← 0
			       HEIGHT ← (WINDOWPROP WINDOW 'HEIGHT)
			       WIDTH ← WIDTH))
          (WINDOWPROP WINDOW 'EXTENT EXTENT)
          (DSPRIGHTMARGIN WIDTH WINDOW)
          (WDISPLAY.REPAINTFN WINDOW (CREATE REGION
					     LEFT ← 0
					     BOTTOM ← 0
					     HEIGHT ← (WINDOWPROP WINDOW 'HEIGHT)
					     WIDTH ← (WINDOWPROP WINDOW 'WIDTH))))))

(WDISPLAY.REPAINTFN
  (LAMBDA (WINDOW REGION)                                    (* kbr: "17-Jul-84 14:00")
    (PROG (HEIGHT X Y Y0 WAVE SCALEX STARTX ENDX STREAM)
          (WDISPLAY.DRAWXAXIS WINDOW REGION)
          (WDISPLAY.DRAWTIMEAXIS WINDOW REGION)
          (SETQ WAVE (WINDOWPROP WINDOW 'WAVE))
          (SETQ SCALEX (WINDOWPROP WINDOW 'SCALEX))
          (SETQ STARTX (ITIMES SCALEX (ADD1 (fetch (REGION LEFT) of REGION))))
          (SETQ ENDX (ITIMES SCALEX (ADD1 (fetch (REGION RIGHT) of REGION))))
          (COND
	    ((NULL WAVE)                                     (* No WAVE stored on WINDOW yet *)
	      (RETURN))
	    ((ARRAYP WAVE)                                   (* WAVE is an array *)
	      (FOR X FROM (IMAX STARTX SCALEX) TO (IMIN ENDX (ARRAYSIZE WAVE)) BY SCALEX
		 DO (SETQ Y (ELT WAVE X))
		    (WDISPLAY.DRAWXY (IQUOTIENT X SCALEX)
				     Y WINDOW)))
	    ((LITATOM WAVE)                                  (* WAVE is a file *)
	      (SETQ STREAM (OPENSTREAM WAVE 'INPUT))
	      (COND
		((AND (NOT (IEQP STARTX 1))
		      (ILEQ STARTX (GETFILEINFO STREAM 'LENGTH)))
		  (SETFILEPTR STREAM (SUB1 STARTX))))
	      (FOR X FROM (IMAX STARTX SCALEX) TO (IMIN ENDX (GETFILEINFO STREAM 'LENGTH))
		 BY SCALEX
		 DO (COND
		      ((NOT (IEQP SCALEX 1))
			(SETFILEPTR STREAM (SUB1 X))))
		    (SETQ Y (SPEECH.BIN STREAM))
		    (WDISPLAY.DRAWXY (IQUOTIENT X SCALEX)
				     Y WINDOW))
	      (CLOSEF STREAM))))))

(WDISPLAY.DRAWXY
  (LAMBDA (X Y WINDOW)                                       (* kbr: "17-Jul-84 14:00")
    (PROG NIL
          (SETQ Y (RANGECHECK Y MIN.SMALLP MAX.SMALLP))
          (DRAWLINE (SUB1 X)
		    WDISPLAY.Y0
		    (SUB1 X)
		    (IPLUS Y WDISPLAY.Y0)
		    1
		    'PAINT WINDOW))))

(WDISPLAY.CLEARW
  (LAMBDA (WINDOW)                                           (* kbr: "17-Jul-84 14:00")
    (PROG (REGION)                                           (* Note: Must do DSPRESET first here.
							     *)
          (DSPRESET WINDOW)
          (DSPXOFFSET (IPLUS (fetch (REGION LEFT) of (WINDOWPROP WINDOW 'REGION))
			     (WINDOWPROP WINDOW 'BORDER))
		      WINDOW)                                (* Draw axes *)
          (SETQ REGION (CREATE REGION
			       LEFT ← 0
			       BOTTOM ← 0
			       HEIGHT ← (WINDOWPROP WINDOW 'HEIGHT)
			       WIDTH ← (WINDOWPROP WINDOW 'WIDTH)))
          (WDISPLAY.DRAWXAXIS WINDOW REGION)
          (WDISPLAY.DRAWTIMEAXIS WINDOW REGION))))

(WDISPLAY.DRAWXAXIS
  (LAMBDA (WINDOW REGION)                                    (* kbr: "17-Jul-84 14:00")
    (PROG (LEFT RIGHT)
          (SETQ LEFT (ITIMES 3 (IQUOTIENT (fetch (REGION LEFT) of REGION)
					  3)))
          (SETQ RIGHT (ITIMES 3 (ADD1 (IQUOTIENT (fetch (REGION RIGHT) of REGION)
						 3))))
          (FOR X FROM LEFT TO RIGHT BY 3 DO (DRAWLINE X WDISPLAY.Y0 X WDISPLAY.Y0 1 'PAINT WINDOW)))))

(WDISPLAY.DRAWTIMEAXIS
  (LAMBDA (WINDOW REGION)                                    (* kbr: "17-Jul-84 14:00")
    (PROG (STARTX ENDX WIDTH SCALEX INCX FONT SW)
          (SETQ SCALEX (WINDOWPROP WINDOW 'SCALEX))
          (SETQ STARTX (ADD1 (ITIMES SCALEX (fetch (REGION LEFT) of REGION))))
          (SETQ ENDX (ADD1 (ITIMES SCALEX (fetch (REGION RIGHT) of REGION))))
          (SETQ WIDTH (WINDOWPROP WINDOW 'WIDTH))
          (SETQ FONT (DSPFONT NIL WINDOW))
          (DRAWLINE (fetch (REGION LEFT) of REGION)
		    WDISPLAY.TIMEAXIS
		    (fetch (REGION RIGHT) of REGION)
		    WDISPLAY.TIMEAXIS 1 'PAINT WINDOW)
          (SETQ INCX (ITIMES 20 SCALEX))
          (SETQ STARTX (ITIMES INCX (IQUOTIENT STARTX INCX)))
          (SETQ ENDX (ITIMES INCX (ADD1 (IQUOTIENT ENDX INCX))))
          (FOR X FROM STARTX TO ENDX BY INCX
	     DO (DRAWLINE (IQUOTIENT X SCALEX)
			  WDISPLAY.TIMEAXIS
			  (IQUOTIENT X SCALEX)
			  (IPLUS WDISPLAY.TIMEAXIS 4)
			  1
			  'PAINT WINDOW)
		(SETQ SW (STRINGWIDTH X FONT))
		(COND
		  ((ODDP (IQUOTIENT X INCX))
		    (MOVETO (IDIFFERENCE (IQUOTIENT X SCALEX)
					 (IQUOTIENT SW 2))
			    0 WINDOW)
		    (PRIN1 X WINDOW)))))))

(WDISPLAY.BUTTONEVENTFN
  (LAMBDA (WINDOW)                                           (* kbr: "17-Jul-84 14:00")
    (PROG NIL
          (COND
	    ((LASTMOUSESTATE LEFT)
	      (TOTOPW WINDOW)
	      (WDISPLAY.LEFTBUTTONFN WINDOW))
	    ((LASTMOUSESTATE MIDDLE)
	      (TOTOPW WINDOW))))))

(WDISPLAY.LEFTBUTTONFN
  (LAMBDA (WINDOW)                                           (* kbr: "17-Jul-84 14:00")
    (PROG (POSITION)
          (SETQ POSITION (CURSORPOSITION NIL WINDOW))
          (replace (POSITION YCOORD) of POSITION with (IDIFFERENCE (fetch (POSITION YCOORD)
								      of POSITION)
								   WDISPLAY.Y0))
          (PRINT POSITION PROMPTWINDOW))))
)
(MOVD 'WDISPLAY.WAVE 'SD)
(MOVD 'WDISPLAY.WAVE1 'SD1)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1222 9607 (WDISPLAY.CREATEW 1232 . 2228) (WDISPLAY.SCALEX 2230 . 2404) (WDISPLAY.WAVE 
2406 . 2906) (WDISPLAY.WAVE1 2908 . 4625) (WDISPLAY.REPAINTFN 4627 . 6164) (WDISPLAY.DRAWXY 6166 . 
6470) (WDISPLAY.CLEARW 6472 . 7208) (WDISPLAY.DRAWXAXIS 7210 . 7668) (WDISPLAY.DRAWTIMEAXIS 7670 . 
8900) (WDISPLAY.BUTTONEVENTFN 8902 . 9203) (WDISPLAY.LEFTBUTTONFN 9205 . 9605)))))
STOP