(FILECREATED " 2-Dec-84 13:07:05" {ERIS}<SPEECH>PROSE>COMMUNICARD.;10 12614  

      changes to:  (FNS ANSWERING.MACHINE PLAYIT TEST.RECORD STORE.MESSAGE WAIT.FOR.CALL DIAL.DIGIT 
			DIAL STATUS TONE? TEST.TONE TEST.PLAY COMMUNICARD.SETUP OFF.HAND OFF.HOOK 
			OFF.LINE OFF.PHONE ON.HAND ON.HOOK ON.LINE ON.PHONE RINGING? TEST 
			INIT.ANSWERING.MACHINE CORRECT TEST.PLAY.FILE INP OUT HEX POLL)
		   (VARS COMMUNICARDCOMS SMEAR.LIMIT SLOW.LIMIT FAST.LIMIT BEEP.LIMIT BACKWARDS.LIMIT 
			 SPEECH3.LIMIT SPEECH2.LIMIT SPEECH1.LIMIT RESPONSE.LIMIT SPEECH.THRESHOLD 
			 RDY TONE MONITOR HAND ENB LINE PHONE OH DATA DTMF RST CTRL AROUNDEXITFNS 
			 BANK)

      previous date: "30-Nov-84 17:10:18" {ERIS}<SPEECH>PROSE>COMMUNICARD.;1)


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

(PRETTYCOMPRINT COMMUNICARDCOMS)

(RPAQQ COMMUNICARDCOMS ((VARS BACKWARDS.LIMIT BANK BEEP.LIMIT CTRL DATA DTMF ENB FAST.LIMIT HAND LINE 
			      MONITOR OH PHONE RDY RESPONSE.LIMIT RST SLOW.LIMIT SMEAR.LIMIT 
			      SPEECH.THRESHOLD SPEECH1.LIMIT SPEECH2.LIMIT SPEECH3.LIMIT TONE)
	(FNS ANSWERING.MACHINE COMMUNICARD.SETUP CORRECT DIAL DIAL.DIGIT HEX HEXCHAR 
	     INIT.ANSWERING.MACHINE INP OFF.HAND OFF.HOOK OFF.LINE OFF.PHONE ON.HAND ON.HOOK ON.LINE 
	     ON.PHONE OUT PLAYIT POLL RECORDIT RINGING? STATUS STORE.MESSAGE TEST TEST.PLAY 
	     TEST.PLAY.FILE TEST.RECORD TEST.TONE TONE? WAIT.FOR.CALL)))

(RPAQQ BACKWARDS.LIMIT 5000)

(RPAQQ BANK 4)

(RPAQQ BEEP.LIMIT 2000)

(RPAQQ CTRL 630)

(RPAQQ DATA 631)

(RPAQQ DTMF 628)

(RPAQQ ENB 8)

(RPAQQ FAST.LIMIT 5000)

(RPAQQ HAND 16)

(RPAQQ LINE 4)

(RPAQQ MONITOR 32)

(RPAQQ OH 1)

(RPAQQ PHONE 2)

(RPAQQ RDY 128)

(RPAQQ RESPONSE.LIMIT 30000)

(RPAQQ RST 629)

(RPAQQ SLOW.LIMIT 5000)

(RPAQQ SMEAR.LIMIT 5000)

(RPAQQ SPEECH.THRESHOLD 128)

(RPAQQ SPEECH1.LIMIT 30000)

(RPAQQ SPEECH2.LIMIT 5000)

(RPAQQ SPEECH3.LIMIT 5000)

(RPAQQ TONE 64)
(DEFINEQ

(ANSWERING.MACHINE
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 13:06")
    (PROG (PHONEMESSAGESTREAM)
          (SETQ PHONEMESSAGESTREAM (OPENSTREAM (QUOTE {IVY}<JELLINEK>SPEECH>MESSAGES.SPEECH)
					       (QUOTE APPEND)))
          (printout STATUSSTREAM "-- Started at " (DATE)
		    " --" T)
          (while (NOT (KEYDOWNP (QUOTE STOP)))
	     do (WAIT.FOR.CALL)
		(OFF.HOOK)
		(printout STATUSSTREAM "call at " (DATE)
			  T)
		(PLAYIT SPEECH1.ARRAY SPEECH1.LIMIT)
		(PLAYIT BEEP.ARRAY BEEP.LIMIT)
		(RECORDIT RESPONSE.ARRAY RESPONSE.LIMIT)
		(PLAYIT SPEECH2.ARRAY SPEECH2.LIMIT)
		(PLAYIT RESPONSE.ARRAY RESPONSE.LIMIT)
		(PLAYIT BACKWARDS.ARRAY BACKWARDS.LIMIT)
		(PLAYIT RESPONSE.ARRAY RESPONSE.LIMIT (QUOTE BACKWARDS))
		(PLAYIT SLOW.ARRAY SLOW.LIMIT)
		(PLAYIT RESPONSE.ARRAY RESPONSE.LIMIT (QUOTE SLOW))
		(PLAYIT FAST.ARRAY FAST.LIMIT)
		(PLAYIT RESPONSE.ARRAY RESPONSE.LIMIT (QUOTE FAST))
		(PLAYIT SMEAR.ARRAY SMEAR.LIMIT)
		(PLAYIT RESPONSE.ARRAY RESPONSE.LIMIT (QUOTE SMEAR))
		(PLAYIT SPEECH3.ARRAY SPEECH3.LIMIT)
		(BLOCK 2000)
		(ON.HOOK)
		(STORE.MESSAGE PHONEMESSAGESTREAM RESPONSE.ARRAY))
          (CLOSEF PHONEMESSAGESTREAM])

(COMMUNICARD.SETUP
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.RESET)
    (BUS.OUTPUT RST 0)
    (BUS.OUTPUT CTRL])

(CORRECT
  [LAMBDA (DATUM)                                            (* hdj " 1-Dec-84 17:21")
    (if (IGREATERP DATUM 127)
	then (IDIFFERENCE DATUM 128)
      else DATUM])

(DIAL
  [LAMBDA (PHONE.NUMBER)                                     (* hdj " 2-Dec-84 11:46")
    (PROG ((STRING (SUBSTRING PHONE.NUMBER 1)))
          (for X from 1 to (NCHARS STRING) do (DIAL.DIGIT (GNC STRING])

(DIAL.DIGIT
  [LAMBDA (DIGIT)                                            (* hdj " 2-Dec-84 12:07")
    (if (ZEROP DIGIT)
	then (SETQ DIGIT 10))
    (if (NUMBERP DIGIT)
	then (for X from 1 to DIGIT
		do (PRIN3 ".")
		   (ON.HOOK)
		   (BLOCK 200)
		   (OFF.HOOK)
		   (BLOCK 100))
	     (TERPRI)
	     (BLOCK 2000])

(HEX
  [LAMBDA (STR)                                              (* hdj "30-Nov-84 16:37")
    (PROG (LENGTH STRING)
          (SETQ STRING (SUBSTRING STR 1))
          (SETQ LENGTH (NCHARS STRING))
          (RETURN (for X from 1 to LENGTH sum (TIMES (EXPT 16 (IDIFFERENCE LENGTH X))
						     (HEXCHAR (GNC STRING])

(HEXCHAR
  [LAMBDA (CHAR)                                             (* hdj "30-Nov-84 16:36")
    (SELECTQ CHAR
	     ((0 1 2 3 4 5 6 7 8 9)
	       CHAR)
	     (A 10)
	     (B 11)
	     (C 12)
	     (D 13)
	     (E 14)
	     (F 15)
	     NIL])

(INIT.ANSWERING.MACHINE
  [LAMBDA NIL                                                (* hdj " 1-Dec-84 17:33")

          (* * comment)


    (PROG NIL
          (SETQ SPEECH1.ARRAY (ARRAY SPEECH1.LIMIT (QUOTE BYTE)
				     0 0))
          (SETQ SPEECH2.ARRAY (ARRAY SPEECH2.LIMIT (QUOTE BYTE)
				     0 0))
          (SETQ SPEECH3.ARRAY (ARRAY SPEECH3.LIMIT (QUOTE BYTE)
				     0 0))
          (SETQ RESPONSE.ARRAY (ARRAY RESPONSE.LIMIT (QUOTE BYTE)
				      0 0))
          (SETQ BACKWARDS.ARRAY (ARRAY BACKWARDS.LIMIT (QUOTE BYTE)
				       0 0))
          (printout T 
"now run TEST.RECORD on SPEECH1.ARRAY, SPEECH2.ARRAY, SPEECH3.ARRAY, RESPONSE.ARRAY, and BACKWARDS.ARRAY."
		    T])

(INP
  [LAMBDA (A)                                                (* hdj "30-Nov-84 17:14")
    (BUS.INPUT A])

(OFF.HAND
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.OUTPUT CTRL (LOGAND (LOGNOT HAND)
			     (BUS.INPUT CTRL])

(OFF.HOOK
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.OUTPUT CTRL (LOGOR (BUS.INPUT CTRL)
			    OH])

(OFF.LINE
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.OUTPUT CTRL (LOGAND (LOGNOT LINE)
			     (BUS.INPUT CTRL])

(OFF.PHONE
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.OUTPUT CTRL (LOGOR PHONE (BUS.INPUT CTRL])

(ON.HAND
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.OUTPUT CTRL (LOGOR HAND (BUS.INPUT CTRL])

(ON.HOOK
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.OUTPUT CTRL (LOGAND (BUS.INPUT CTRL)
			     (LOGNOT OH])

(ON.LINE
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.OUTPUT CTRL (LOGOR LINE (BUS.INPUT CTRL])

(ON.PHONE
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (BUS.OUTPUT CTRL (LOGAND (LOGNOT PHONE)
			     (BUS.INPUT CTRL])

(OUT
  [LAMBDA (A D)                                              (* hdj "30-Nov-84 17:14")
    (BUS.OUTPUT A D])

(PLAYIT
  [LAMBDA (ARRAY LIMIT OPTION)                               (* hdj " 2-Dec-84 12:32")
    (SELECTQ OPTION
	     [SLOW (for DATUM from 0 to (SUB1 LIMIT)
		      do (BUS.OUTPUT DATA (ELT ARRAY DATUM))
			 (BUS.OUTPUT DATA (ELT ARRAY DATUM]
	     [FAST (for DATUM from 0 to (SUB1 LIMIT) by 2
		      do (BUS.OUTPUT DATA (LRSH (IPLUS (ELT ARRAY DATUM)
						       (ELT ARRAY (ADD1 DATUM)))
						1]
	     [BACKWARDS (for DATUM from (SUB1 LIMIT) to 0 by -1 do (BUS.OUTPUT DATA (ELT ARRAY DATUM]
	     [SMEAR (for DATUM from 0 to (IDIFFERENCE LIMIT 3)
		       do (BUS.OUTPUT DATA (ELT ARRAY (IPLUS DATUM 2)))
			  (BUS.OUTPUT DATA (ELT ARRAY (IPLUS DATUM 1)))
			  (BUS.OUTPUT DATA (ELT ARRAY DATUM]
	     (for DATUM from 0 to (SUB1 LIMIT) do (BUS.OUTPUT DATA (ELT ARRAY DATUM])

(POLL
  [LAMBDA (ADDR DATA)                                        (* hdj "30-Nov-84 16:18")
    (BUS.OUTPUT ADDR DATA])

(RECORDIT
  [LAMBDA (ARRAY LIMIT)                                      (* hdj " 1-Dec-84 17:00")
    (BUS.OUTPUT DATA SPEECH.THRESHOLD)
    (for DATUM from 0 to (SUB1 LIMIT) do (SETA ARRAY DATUM (BUS.INPUT DATA])

(RINGING?
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:26")
    (ZEROP (LOGAND MONITOR (BUS.INPUT CTRL])

(STATUS
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 12:03")
    (PROG (STATUS)
          (SETQ STATUS (BUS.INPUT CTRL))
          (printout T "Status: ")
          (printout T (if (ZEROP (LOGAND OH STATUS))
			  then "on"
			else "off")
		    "hook/"
		    (if (ZEROP (LOGAND PHONE STATUS))
			then ""
		      else "no ")
		    "phone/"
		    (if (ZEROP (LOGAND LINE STATUS))
			then "off"
		      else "on")
		    "line/"
		    (if (ZEROP (LOGAND HAND STATUS))
			then "off"
		      else "on")
		    "hand/"
		    (if (ZEROP (LOGAND MONITOR STATUS))
			then ""
		      else "not ")
		    "ringing/"
		    (if (ZEROP (LOGAND TONE STATUS))
			then "no "
		      else "")
		    "tone " T])

(STORE.MESSAGE
  [LAMBDA (FILE SAMPLE)                                      (* hdj " 2-Dec-84 13:05")
    (\BOUTS FILE (fetch (ARRAYP BASE) of BEEP.ARRAY)
	    0
	    (ARRAYSIZE BEEP.ARRAY))
    (\BOUTS FILE (fetch (ARRAYP BASE) of SAMPLE)
	    0
	    (ARRAYSIZE SAMPLE])

(TEST
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 11:27")
    (while T do (if (RINGING?)
		    then (OFF.HOOK)
			 (BUS.OUTPUT DATA SPEECH.THRESHOLD)
			 (for DATUM from 0 to (SUB1 SPEECH.LIMIT) do (SETA SPEECHARRAY DATUM
									   (BUS.INPUT DATA)))
			 (ON.HOOK])

(TEST.PLAY
  [LAMBDA (ARRAY LIMIT OPTION)                               (* hdj " 2-Dec-84 11:24")
    (while T do (if (RINGING?)
		    then (OFF.HOOK)
			 (PLAYIT ARRAY LIMIT OPTION)
			 (ON.HOOK])

(TEST.PLAY.FILE
  [LAMBDA (FILE)                                             (* hdj " 1-Dec-84 17:13")
    (while T do (if (RINGING?)
		    then (OFF.HOOK)
			 (for DATUM from 0 to (SUB1 SPEECH.LIMIT) do (BUS.OUTPUT DATA (BIN FILE)))
			 (ON.HOOK])

(TEST.RECORD
  [LAMBDA (ARRAY LIMIT)                                      (* hdj " 2-Dec-84 12:26")
    (while T do (if (RINGING?)
		    then (OFF.HOOK)
			 (BUS.OUTPUT DATA SPEECH.THRESHOLD)
			 (PRIN1 "Recording... ")
			 (RECORDIT ARRAY LIMIT)
			 (printout T "done." T)
			 (PLAYIT ARRAY LIMIT)
			 (BLOCK 1000)
			 (ON.HOOK)
			 (BLOCK 3000])

(TEST.TONE
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 12:20")
    (PROG (THE.TONE)
          (while T
	     do (BLOCK)
		(COND
		  ((RINGING?)
		    (OFF.HOOK)
		    (BLOCK 2000)
		    (COND
		      ((NOT (ZEROP (LOGAND (BUS.INPUT CTRL)
					   TONE)))
			(printout T "tone " (BUS.INPUT DTMF)
				  T)
			(BUS.OUTPUT DTMF 0)))
		    (ON.HOOK])

(TONE?
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 12:10")
    (COND
      ((ZEROP (LOGAND (BUS.INPUT CTRL)
		      TONE))
	NIL)
      (T (PROG1 (LOGAND 15 (BUS.INPUT DTMF))
		(BUS.OUTPUT DTMF 0])

(WAIT.FOR.CALL
  [LAMBDA NIL                                                (* hdj " 2-Dec-84 13:00")
    (WHILE (NOT (RINGING?)) DO (BLOCK])
)
(PUTPROPS COMMUNICARD COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2007 12532 (ANSWERING.MACHINE 2017 . 3362) (COMMUNICARD.SETUP 3364 . 3551) (CORRECT 
3553 . 3755) (DIAL 3757 . 4013) (DIAL.DIGIT 4015 . 4409) (HEX 4411 . 4802) (HEXCHAR 4804 . 5062) (
INIT.ANSWERING.MACHINE 5064 . 5839) (INP 5841 . 5963) (OFF.HAND 5965 . 6154) (OFF.HOOK 6156 . 6329) (
OFF.LINE 6331 . 6520) (OFF.PHONE 6522 . 6691) (ON.HAND 6693 . 6859) (ON.HOOK 6861 . 7047) (ON.LINE 
7049 . 7215) (ON.PHONE 7217 . 7407) (OUT 7409 . 7534) (PLAYIT 7536 . 8531) (POLL 8533 . 8665) (
RECORDIT 8667 . 8923) (RINGING? 8925 . 9086) (STATUS 9088 . 9962) (STORE.MESSAGE 9964 . 10283) (TEST 
10285 . 10655) (TEST.PLAY 10657 . 10898) (TEST.PLAY.FILE 10900 . 11212) (TEST.RECORD 11214 . 11629) (
TEST.TONE 11631 . 12086) (TONE? 12088 . 12359) (WAIT.FOR.CALL 12361 . 12530)))))
STOP