(* ;;-*-LISP-*- KEEP EMACS HAPPY ******************************** * * WAVE DISPLAY * ****************************************************************) (DEFVAR WDISPLAY.TIMEAXIS 15) (DEFVAR WDISPLAY.YM128 (1+ WDISPLAY.TIMEAXIS)) (DEFVAR WDISPLAY.Y0 (+ WDISPLAY.YM128 128)) (DEFVAR WDISPLAY.Y127 (+ WDISPLAY.Y0 127)) (DEFVAR WDISPLAY.WIDTH 700) (DEFEXPR (WDISPLAY.CREATEW TITLE) (* 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) )) (DEFEXPR (WDISPLAY.SCALEX WINDOW SCALEX) (PROG () (WINDOWPROP WINDOW 'SCALEX SCALEX) )) (DEFVAR WDISPLAY.WINDOW) (DEFEXPR (WDISPLAY.WAVE WAVE WINDOW) (* Display array or file WAVE in WINDOW. Default window to WDISPLAY.WINDOW *) (PROG () (COND ((NULL WINDOW) (COND ((NULL WDISPLAY.WINDOW) (SETQ WDISPLAY.WINDOW (WDISPLAY.CREATEW WAVE)))) (SETQ WINDOW WDISPLAY.WINDOW))) (WDISPLAY.WAVE1 WAVE WINDOW) )) (MOVD 'WDISPLAY.WAVE 'SD) (DEFEXPR (WDISPLAY.WAVE1 WAVE WINDOW) (* 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 (+ (REGION.LEFT (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))) )) (MOVD 'WDISPLAY.WAVE1 'SD1) (DEFEXPR (WDISPLAY.REPAINTFN WINDOW REGION) (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 (x SCALEX (1+ (REGION.LEFT REGION)))) (SETQ ENDX (x SCALEX (1+ (REGION.RIGHT 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 (/ X SCALEX) Y WINDOW))) ((LITATOM WAVE) (* WAVE is a file *) (SETQ STREAM (OPENSTREAM WAVE 'INPUT)) (COND ((AND (<> STARTX 1) (<= STARTX (GETFILEINFO STREAM 'LENGTH))) (SETFILEPTR STREAM (1- STARTX)))) (FOR X FROM (IMAX STARTX SCALEX) TO (IMIN ENDX (GETFILEINFO STREAM 'LENGTH)) BY SCALEX DO (COND ((<> SCALEX 1) (SETFILEPTR STREAM (1- X)))) (SETQ Y (SPEECH.BIN STREAM)) (WDISPLAY.DRAWXY (/ X SCALEX) Y WINDOW)) (CLOSEF STREAM))) )) (DEFEXPR (WDISPLAY.DRAWXY X Y WINDOW) (PROG () (SETQ Y (RANGECHECK Y MIN.SMALLP MAX.SMALLP)) (DRAWLINE (1- X) WDISPLAY.Y0 (1- X) (+ Y WDISPLAY.Y0) 1 'PAINT WINDOW) )) (DEFEXPR (WDISPLAY.CLEARW WINDOW) (PROG (REGION) (* Note: Must do DSPRESET first here. *) (DSPRESET WINDOW) (DSPXOFFSET (+ (REGION.LEFT (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) )) (DEFEXPR (WDISPLAY.DRAWXAXIS WINDOW REGION) (PROG (LEFT RIGHT) (SETQ LEFT (x 3 (/ (REGION.LEFT REGION) 3))) (SETQ RIGHT (x 3 (1+ (/ (REGION.RIGHT REGION) 3)))) (FOR X FROM LEFT TO RIGHT BY 3 DO (DRAWLINE X WDISPLAY.Y0 X WDISPLAY.Y0 1 'PAINT WINDOW)) )) (DEFEXPR (WDISPLAY.DRAWTIMEAXIS WINDOW REGION) (PROG (STARTX ENDX WIDTH SCALEX INCX FONT SW) (SETQ SCALEX (WINDOWPROP WINDOW 'SCALEX)) (SETQ STARTX (1+ (x SCALEX (REGION.LEFT REGION)))) (SETQ ENDX (1+ (x SCALEX (REGION.RIGHT REGION)))) (SETQ WIDTH (WINDOWPROP WINDOW 'WIDTH)) (SETQ FONT (DSPFONT NIL WINDOW)) (DRAWLINE (REGION.LEFT REGION) WDISPLAY.TIMEAXIS (REGION.RIGHT REGION) WDISPLAY.TIMEAXIS 1 'PAINT WINDOW) (SETQ INCX (x 20 SCALEX)) (SETQ STARTX (x INCX (/ STARTX INCX))) (SETQ ENDX (x INCX (1+ (/ ENDX INCX)))) (FOR X FROM STARTX TO ENDX BY INCX DO (DRAWLINE (/ X SCALEX) WDISPLAY.TIMEAXIS (/ X SCALEX) (+ WDISPLAY.TIMEAXIS 4) 1 'PAINT WINDOW) (SETQ SW (STRINGWIDTH X FONT)) (COND ((ODDP (/ X INCX)) (MOVETO (- (/ X SCALEX) (/ SW 2)) 0 WINDOW) (PRIN1 X WINDOW)))) )) (* **************************************************************** * * MOUSE ACTION * ****************************************************************) (DEFEXPR (WDISPLAY.BUTTONEVENTFN WINDOW) (PROG () (COND ((LASTMOUSESTATE LEFT) (TOTOPW WINDOW) (WDISPLAY.LEFTBUTTONFN WINDOW)) ((LASTMOUSESTATE MIDDLE) (TOTOPW WINDOW))) )) (DEFEXPR (WDISPLAY.LEFTBUTTONFN WINDOW) (PROG (POSITION) (SETQ POSITION (CURSORPOSITION NIL WINDOW)) (SETF (POSITION.YCOORD POSITION) (- (POSITION.YCOORD POSITION) WDISPLAY.Y0)) (PRINT POSITION PROMPTWINDOW) )) STOP