(FILECREATED " 6-Aug-84 02:34:52" {FLOPPY}WAVEEDIT.;1 6195   

      changes to:  (FNS HAMMING WAVE.MAKEMAG WAVEEDITMENUINIT HAMMER)
		   (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)                                                (* edited: " 6-Aug-84 01:26")
    (PROG ((ALPHA .54))
          (RETURN (FPLUS ALPHA (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))
					    T])

(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 (479 5959 (CLOSEWS 489 . 636) (HAMMING 638 . 1007) (MAKEWINDOWS 1009 . 1579) (PLOTARRAY 
1581 . 3089) (SCALARTOVECTOR 3091 . 3531) (TransformY 3533 . 3743) (WAVE.MAKEMAG 3745 . 4917) (
WAVEEDITMENUINIT 4919 . 5957)))))
STOP