(FILECREATED " 5-Aug-84 04:28:17" {ERIS}<SPEECH>WORK>WAVEEDIT.;5 6167   

      changes to:  (FNS WAVE.MAKEMAG WAVEEDITMENUINIT HAMMER HAMMING)
		   (VARS WAVEEDITCOMS)

      previous date: " 5-Aug-84 01:35:58" {ERIS}<SPEECH>WORK>WAVEEDIT.;2)


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

(PRETTYCOMPRINT WAVEEDITCOMS)

(RPAQQ WAVEEDITCOMS ((FNS CLOSEWS HAMMING MAKEWINDOWS PLOTARRAY SCALARTOVECTOR TransformY 
			  WAVE.MAKEMAG WAVEEDITMENUINIT)
		     (MACROS TransformY)))
(DEFINEQ

(CLOSEWS
  [LAMBDA (WL)                                               (* hdj " 4-Aug-84 18:04")
    (for X in WL do (CLOSEW X])

(HAMMING
  [LAMBDA (N)                                                (* hdj " 5-Aug-84 03:20")
    (PROG ((ALPHA .54))
          (RETURN (FTIMES (FDIFFERENCE 1 ALPHA)
			  (COS (FTIMES (FPLUS (GENVEC 1.0 (FLOAT N)
						      1.0 1)
					      (FMINUS (FQUOTIENT N 2.0)))
				       (FQUOTIENT (FTIMES 2.0 PI)
						  N])

(MAKEWINDOWS
  [LAMBDA (N REGION)                                         (* hdj " 4-Aug-84 18:03")
    (PROG ((LEFT (fetch (REGION LEFT) of REGION))
	   (WIDTH (fetch (REGION WIDTH) of REGION))
	   (BOTTOM (fetch (REGION BOTTOM) of REGION))
	   (HEIGHT (fetch (REGION HEIGHT) of REGION)))
          (RETURN (for X from 0 to (SUB1 N) collect (CREATEW (CREATEREGION
							       LEFT
							       (IPLUS (ITIMES X (IQUOTIENT HEIGHT N))
								      BOTTOM)
							       WIDTH
							       (IQUOTIENT HEIGHT N])

(PLOTARRAY
  [LAMBDA (ARRAY WINDOW HORIZREPEAT FILLED?)                 (* hdj " 5-Aug-84 00:58")
    (PROG ((WINDOWHEIGHT (GETWINDOWPROP WINDOW (QUOTE HEIGHT)))
	   (WINDOWWIDTH (GETWINDOWPROP WINDOW (QUOTE WIDTH)))
	   (MINVALUE MAX.FLOAT)
	   (MAXVALUE MIN.FLOAT)
	   ZERO ORIGIN LASTELT OLDVALUE)
          (CLEARW WINDOW)
          (SETQ HORIZREPEAT (OR HORIZREPEAT 1))
          (SETQ ORIGIN (ARRAYORIG ARRAY))
          [SETQ LASTELT (IPLUS (ARRAYSIZE ARRAY)
			       (SUB1 (ARRAYORIG ARRAY]
          (for X from ORIGIN to LASTELT
	     do (SETQ MINVALUE (FMIN (ELT ARRAY X)
				     MINVALUE))
		(SETQ MAXVALUE (FMAX (ELT ARRAY X)
				     MAXVALUE)))
          (SETQ ZERO (TransformY 0 WINDOWHEIGHT MAXVALUE MINVALUE))
          (if FILLED?
	      then (for ELEMENT from ORIGIN to (ITIMES HORIZREPEAT LASTELT)
		      do (DRAWLINE ELEMENT ZERO ELEMENT (TransformY (ELT ARRAY (IQUOTIENT
									   (ADD1 ELEMENT)
									   HORIZREPEAT))
								    WINDOWHEIGHT MAXVALUE MINVALUE)
				   1
				   (QUOTE PAINT)
				   WINDOW))
	    else (SETQ OLDVALUE (TransformY (ELT ARRAY ORIGIN)
					    WINDOWHEIGHT MAXVALUE MINVALUE))
		 (for ELEMENT from ORIGIN to (ITIMES HORIZREPEAT LASTELT)
		    do (DRAWLINE ELEMENT OLDVALUE ELEMENT (SETQ OLDVALUE
				   (TransformY (ELT ARRAY (IQUOTIENT (ADD1 ELEMENT)
								     HORIZREPEAT))
					       WINDOWHEIGHT MAXVALUE MINVALUE))
				 1
				 (QUOTE PAINT)
				 WINDOW])

(SCALARTOVECTOR
  [LAMBDA (SCALAR VECTORLENGTH VECTORORIGIN)                 (* hdj " 4-Aug-84 23:12")

          (* * creates an array of VECTORLENGTH repetitions of SCALAR -
	  a FLOATP)


    (PROG ((VECTOR (ARRAY VECTORLENGTH (QUOTE FLOATP)
			  0.0 VECTORORIGIN)))
          (for X from VECTORORIGIN to (IPLUS VECTORLENGTH (SUB1 VECTORORIGIN))
	     do (SETA VECTOR X SCALAR))
          (RETURN VECTOR])

(TransformY
  [LAMBDA (Yw WindowHeight MaxValue MinValue)                (* hdj " 4-Aug-84 17:07")
    (FIX (FTIMES (FQUOTIENT WindowHeight (FDIFFERENCE MaxValue MinValue))
		 (FDIFFERENCE Yw MinValue])

(WAVE.MAKEMAG
  [LAMBDA (WAVESAMPLE WAVEW)                                 (* hdj " 5-Aug-84 04:23")
    (DECLARE (LOCALVARS . T))
    (PROG ((PASSES 8)
	   (BHALFTONE (ARRAYBASE HALFTONE))
	   (BASE (BASEADDROFY WAVEW 0))
	   (SCREENWIDTHINWORDS 64)
	   [DD (fetch IMAGEDATA of (GETWINDOWPROP WAVEW 'DSP]
	   PASSESMINUS1 START END WINDOWBASE XPOS BARHEIGHT TWICEFFTSHIFT TWICEGWIDTH 
	   TWICEARRAYLENGTH ARRAYLENGTH HALFARRAYLENGTH TBL1 TBL2 TBL3 TBL4 TBL5 TBL6 TBL7 TBL8)
          (CLEARW WAVEW)
          [SETQ WINDOWBASE (\ADDBASE BASE (IMINUS (ITIMES 256 64]
          (SETQ TWICEFFTSHIFT (IPLUS FFTSHIFT FFTSHIFT))
          (SETQ ARRAYLENGTH (LLSH 1 PASSES))
          (SETQ TWICEARRAYLENGTH (IPLUS ARRAYLENGTH ARRAYLENGTH))
          (SETQ HALFARRAYLENGTH (HALF ARRAYLENGTH))
          (SETQ BLOGMAGNITUDE (ARRAYBASE STRIPEDATA))
          (SETQ BLOGMAGNITUDE1 (\ADDBASE BLOGMAGNITUDE 1))
          (IBLT2 BLOGMAGNITUDE BHALFTONE (\DSPTRANSFORMX 0 DD)
		 WINDOWBASE SCREENWIDTHINWORDS 2 4 HALFARRAYLENGTH)
          (IBLT2 BLOGMAGNITUDE1 BHALFTONE (IPLUS (\DSPTRANSFORMX 0 DD)
						 4)
		 WINDOWBASE SCREENWIDTHINWORDS 2 4 HALFARRAYLENGTH])

(WAVEEDITMENUINIT
  [LAMBDA NIL                                                (* hdj " 5-Aug-84 04:12")
    (SETQ WAVESAMPLE (ARRAY 256 'FLOATP 0.0 1))
    [for X from 1 to 256 do (SETA WAVESAMPLE X (ELT WAVE (IPLUS 15050 X]
    (ADDMENU (SETQ WAVEEDITMENU (create MENU
					TITLE ← "Wave display menu"
					ITEMS ← '(("Show a sample speech waveform" (BKSYSBUF 
								 "(PLOTARRAY WAVESAMPLE WAVEW 2)")
										   
								 "Shows a sample speech waveform")
					 ("Create a Hamming window" (BKSYSBUF 
					     "(PLOTARRAY (SETQ HAMMING (HAMMING 256)) WAVEW 2 T)")
								    
						       "Calculates and displays a Hamming window")
					 ("Show wave times Hamming" (BKSYSBUF 
					    "(PLOTARRAY (FTIMES HAMMING WAVESAMPLE)
	   WAVEW 2)")
								    
							  "Multiplies waveform by Hamming window")
					 ("Display magnitude" (BKSYSBUF "foo")
							      "shows magnitude of ???")
					 ("Draw stripe" (BKSYSBUF "(WAVE.MAKEMAG WAVESAMPLE WAVEW)")
							"Draws result of FFT as vertical stripe"])
)
(DECLARE: EVAL@COMPILE 

(PUTPROPS TransformY MACRO [LAMBDA (Yw WindowHeight MaxValue MinValue)
			     (FIX (FTIMES (FQUOTIENT WindowHeight (FDIFFERENCE MaxValue MinValue))
					  (FDIFFERENCE Yw MinValue])
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (490 5931 (CLOSEWS 500 . 647) (HAMMING 649 . 979) (MAKEWINDOWS 981 . 1551) (PLOTARRAY 
1553 . 3061) (SCALARTOVECTOR 3063 . 3503) (TransformY 3505 . 3715) (WAVE.MAKEMAG 3717 . 4889) (
WAVEEDITMENUINIT 4891 . 5929)))))
STOP