(FILECREATED "13-Jul-84 02:50:21" {ERIS}<SPEECH>SCOPE.FPKG;22 6714   

      changes to:  (FNS SCOPE.PRINT)

      previous date: "12-Jul-84 18:23:14" {ERIS}<SPEECH>SCOPE.FPKG;21)


(* Copyright (c) 1984 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT SCOPECOMS)

(RPAQQ SCOPECOMS ((INITVARS (SCOPE.WINDOW NIL)
			    (SCOPE.U 0)
			    (SCOPE.V 0)
			    (SCOPE.YMIN -1.0)
			    (SCOPE.YMAX 1.0))
		  (FNS SCOPE.SETUP SCOPE.CLEAR SCOPE.POINT SCOPE.PRINT SCOPE.DRAWTO SCOPE.STEP 
		       SCOPE.WIDTH)))

(RPAQ? SCOPE.WINDOW NIL)

(RPAQ? SCOPE.U 0)

(RPAQ? SCOPE.V 0)

(RPAQ? SCOPE.YMIN -1.0)

(RPAQ? SCOPE.YMAX 1.0)
(DEFINEQ

(SCOPE.SETUP
  [LAMBDA (YMIN YMAX NEWFLG)                                 (* pkh: " 2-Jul-84 18:55")
                                                             (* Initializes the window which traces resonators and 
							     registers in the synthesizer)
    (PROG (STARTX STARTY)
          (COND
	    ((AND NEWFLG (NEQ (EVALV 'SCOPE.WINDOW)
			      'NOBIND)
		  (WINDOWP SCOPE.WINDOW))
	      (CLOSEW SCOPE.WINDOW)))                        (* No scope window%, or NEWFLG is T;
							     Create window from scratch)
          (SETQ SCOPE.WINDOW (CREATEW (CREATEREGION 20 20 700 160)
				      "Oscilloscope Window"))
          (SETQ STARTY (DSPYPOSITION NIL SCOPE.WINDOW))
          (SETQ STARTX (DSPXPOSITION NIL SCOPE.WINDOW))
          (WINDOWPROP SCOPE.WINDOW 'EXTENT
		      (create REGION
			      LEFT ← 0
			      BOTTOM ← STARTY
			      HEIGHT ← -1
			      WIDTH ← (ARRAYSIZE SPEECH.*WAVE*)))
                                                             (* Nothing for file until we synthesize)
          (WINDOWPROP SCOPE.WINDOW 'FILE NIL)
          (SCALED.WINDOW.SETUP SCOPE.WINDOW YMIN YMAX 30 30 'SCOPE.PRINT)
                                                             (* WINDOWPROP SCOPE.WINDOW (QUOTE YMIN) YMIN)
                                                             (* WINDOWPROP SCOPE.WINDOW (QUOTE YMAX) YMAX)
                                                             (* SCOPE.CLEAR)
      SCOPE.WINDOW])

(SCOPE.CLEAR
  [LAMBDA (WINDOW)                                           (* pkh: " 2-Jul-84 19:27")
                                                             (* Clears the oscilloscope window;
							     Should simply call CLEAR.SCALED.WINDOW which is TBW)
    (CLEARW WINDOW)
    (SCALED.WINDOW.PRINT.SCALES SCOPE.WINDOW])

(SCOPE.POINT
  [LAMBDA (Y)                                                (* kbr: "16-May-84 14:05")
    (PROG (HEIGHT)
          (SETQ HEIGHT (WINDOWPROP SCOPE.WINDOW 'HEIGHT))
          (COND
	    ((OR (FLESSP Y SCOPE.YMIN)
		 (FGREATERP Y SCOPE.YMAX))
	      (printout PROMPTWINDOW "SCOPE: " Y " ")
	      (RETURN)))
          (SETQ SCOPE.V (FIXR (FTIMES (FQUOTIENT (FDIFFERENCE Y SCOPE.YMIN)
						 (FDIFFERENCE SCOPE.YMAX SCOPE.YMIN))
				      HEIGHT)))
          (BITMAPBIT SCOPE.WINDOW SCOPE.U SCOPE.V 1])

(SCOPE.PRINT
  [LAMBDA (WINDOW REGION)                                    (* pkh: "13-Jul-84 02:47")
    (PROG (Y0 Y.POS.FOR.XSCALE BOTTOM.X.SCALE.OFFSET YMAX YMIN Y.SCALE.FACTOR ARRAY)
          (SETQ ARRAY (WINDOWPROP WINDOW 'FILE))
          (COND
	    ((NULL ARRAY)
	      (RETURN)))
          (SETQ Y.SCALE.FACTOR (WINDOWPROP WINDOW 'Y.SCALE.FACTOR))
          (SETQ Y.POS.FOR.XSCALE (WINDOWPROP WINDOW 'YPOS.FOR.X.SCALE))
          (SETQ BOTTOM.X.SCALE.OFFSET (WINDOWPROP WINDOW 'BOTTOM.X.SCALE.OFFSET))
          (SETQ YMAX (WINDOWPROP WINDOW 'YMAX))
          (SETQ YMIN (WINDOWPROP WINDOW 'YMIN))
          (SETQ Y0 (WINDOWPROP WINDOW 'Y0))

          (* Read elements in the array from the part of the array corresponding to the region being displayed;
	  check that it isn%'t out of bounds; convert the value according the the scaling factor; draw line from previous x 
	  and y position to the new one)


          (as X Y OLD.X OLD.Y from (COND
				     (REGION (ADD1 (fetch (REGION LEFT) of REGION)))
				     (T 1))
	     to (IMIN [COND
			(REGION (IPLUS (fetch (REGION LEFT) of REGION)
				       (fetch (REGION WIDTH) of REGION)
				       1))
			(T (ADD1 (WINDOWPROP WINDOW 'WIDTH]
		      (ARRAYSIZE ARRAY))
	     do (SETQ Y (ELT ARRAY X))                       (* In the SPEECH.*WAVE* array elements greater than 127 
							     are elements which should be plotted as negative values 
							     in the scope)
		[COND
		  ((IGREATERP Y 127)
		    (SETQ Y (MINUS (IDIFFERENCE Y 127]
		(COND
		  [(FLESSP Y YMIN)
		    (printout PROMPTWINDOW "SCOPE: " Y " ")
		    (SETQ Y (WINDOWPROP WINDOW 'YMIN]
		  [(FGREATERP Y YMAX)
		    (printout PROMPTWINDOW "SCOPE: " Y " ")
		    (SETQ Y (WINDOWPROP WINDOW 'YMAX]
		  (T (SETQ Y (FTIMES Y Y.SCALE.FACTOR))      (* Center around the 0 crossing)
		     (SETQ Y (IPLUS Y0 Y))
		     (COND
		       (OLD.X (DRAWLINE OLD.X OLD.Y X Y 1 'PAINT SCOPE.WINDOW)))
		     (SETQ OLD.Y Y)
		     (SETQ OLD.X X])

(SCOPE.DRAWTO
  [LAMBDA (Y)                                                (* pkh: "10-Jul-84 22:47")
    (PROG (HEIGHT SCOPE.YMIN SCOPE.YMAX V BOTTOM.X.SCALE.OFFSET Y.SCALE.FACTOR Y0)
          (SETQ HEIGHT (WINDOWPROP SCOPE.WINDOW 'HEIGHT))
          (SETQ SCOPE.YMIN (WINDOWPROP SCOPE.WINDOW 'YMIN))
          (SETQ SCOPE.YMAX (WINDOWPROP SCOPE.WINDOW 'YMAX))
          (SETQ BOTTOM.X.SCALE.OFFSET (WINDOWPROP SCOPE.WINDOW 'BOTTOM.X.SCALE.OFFSET))
          (SETQ Y.SCALE.FACTOR (WINDOWPROP SCOPE.WINDOW 'Y.SCALE.FACTOR))
          (SETQ Y0 (WINDOWPROP SCOPE.WINDOW 'Y0))
          (COND
	    ((FLESSP Y SCOPE.YMIN)
	      (printout PROMPTWINDOW "SCOPE: " Y " ")
	      (SETQ Y SCOPE.YMIN))
	    ((FGREATERP Y SCOPE.YMAX)
	      (printout PROMPTWINDOW "SCOPE: " Y " ")
	      (SETQ Y SCOPE.YMAX)))                          (* When integrated with SCALEDWINDOW we compute V using 
							     YSCALEFACTOR)
          (SETQ Y (FTIMES Y Y.SCALE.FACTOR))                 (* Center around the 0 crossing)
          (SETQ Y (IPLUS Y0 Y))
          (COND
	    ((NOT (ZEROP SCOPE.U))
	      (DRAWLINE (SUB1 SCOPE.U)
			SCOPE.V SCOPE.U Y 1 'PAINT SCOPE.WINDOW)))
          (SETQ SCOPE.V Y)
          (SCOPE.STEP])

(SCOPE.STEP
  [LAMBDA NIL                                                (* kbr: "16-May-84 14:05")
    (PROG NIL
          (SETQ SCOPE.U (ADD1 SCOPE.U])

(SCOPE.WIDTH
  [LAMBDA NIL                                                (* kbr: "16-May-84 14:05")
    (WINDOWPROP SCOPE.WINDOW 'WIDTH])
)
(PUTPROPS SCOPE.FPKG COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (659 6633 (SCOPE.SETUP 669 . 2157) (SCOPE.CLEAR 2159 . 2503) (SCOPE.POINT 2505 . 3030) (
SCOPE.PRINT 3032 . 5079) (SCOPE.DRAWTO 5081 . 6320) (SCOPE.STEP 6322 . 6483) (SCOPE.WIDTH 6485 . 6631)
))))
STOP