DEFINITION FOR C MODULE Narrator ;

FROM SYSTEM IMPORT ADDRESS , SHORTSET , STRING ;
FROM Exec IMPORT IOStdReq ;

CONST
  NDB_NEWIORB	= 0 ; (* Use new extended IORB		 *)
  NDB_WORDSYNC	= 1 ; (* Generate word sync messages	 *)
  NDB_SYLSYNC	= 2 ; (* Generate syllable sync messages *)

  NDF_NEWIORB  = { NDB_NEWIORB } ;
  NDF_WORDSYNC = { NDB_WORDSYNC } ;
  NDF_SYLSYNC  = { NDB_SYLSYNC } ;

  (* Error Codes *)

  ND_NoMem	 =  -2 ;	(* Can't allocate memory		*)
  ND_NoAudLib	 =  -3 ;	(* Can't open audio device		*)
  ND_MakeBad	 =  -4 ;	(* Error in MakeLibrary call		*)
  ND_UnitErr	 =  -5 ;	(* Unit other than 0			*)
  ND_CantAlloc	 =  -6 ;	(* Can't allocate audio channel(s)	*)
  ND_Unimpl	 =  -7 ;	(* Unimplemented command		*)
  ND_NoWrite	 =  -8 ;	(* Read for mouth without write first	*)
  ND_Expunged	 =  -9 ;	(* Can't open, deferred expunge bit set *)
  ND_PhonErr	 = -20 ;	(* Phoneme code spelling error		*)
  ND_RateErr	 = -21 ;	(* Rate out of bounds			*)
  ND_PitchErr	 = -22 ;	(* Pitch out of bounds			*)
  ND_SexErr	 = -23 ;	(* Sex not valid			*)
  ND_ModeErr	 = -24 ;	(* Mode not valid			*)
  ND_FreqErr	 = -25 ;	(* Sampling frequency out of bounds	*)
  ND_VolErr	 = -26 ;	(* Volume out of bounds			*)
  ND_DCentErr	 = -27 ;	(* Degree of centralization outof bounds*)
  ND_CentPhonErr = -28 ;	(* Invalid central phon			*)

  (* Input parameters and defaults *)

  DEFPITCH	 = 110 ;	(* Default pitch			*)
  DEFRATE	 = 150 ;	(* Default speaking rate (wpm)		*)
  DEFVOL	 =  64 ;	(* Default volume (full)		*)
  DEFFREQ	 = 22200 ;	(* Default sampling frequency (Hz)	*)
  MALE		 =   0 ;	(* Male vocal tract			*)
  FEMALE	 =   1 ;	(* Female vocal tract			*)
  NATURALF0	 =   0 ;	(* Natural pitch contours		*)
  ROBOTICF0	 =   1 ;	(* Monotone				*)
  DEFSEX	 = MALE ;	(* Default sex				*)
  DEFMODE	 = NATURALF0 ;	(* Default mode				*)

  DEFARTIC	 = 100 ;	(* 100% articulation (normal)		*)
  DEFCENTRAL	 = 000 ;	(* No centralization			*)
  DEFF0PERT	 = 000 ;	(* No F0 Perturbation			*)
  DEFF0ENTHUS	 = 032 ;	(* Default F0 enthusiasm (in 32nds)	*)
  DEFPRIORITY	 = 100 ;	(* Default speaking priority		*)

  (* Parameter bounds *)

  MINRATE	= 40   ; (* Minimum speaking rate		*)
  MAXRATE	= 400  ; (* Maximum speaking rate		*)
  MINPITCH	= 65   ; (* Minimum pitch			*)
  MAXPITCH	= 320  ; (* Maximum pitch			*)
  MINFREQ	= 5000 ; (* Minimum sampling frequency		*)
  MAXFREQ	= 28000; (* Maximum sampling frequency		*)
  MINVOL	= 0    ; (* Minimum volume			*)
  MAXVOL	= 64   ; (* Maximum volume			*)
  MINCENT	= 0    ; (* Minimum degree of centralization	*)
  MAXCENT	= 100  ; (* Maximum degree of centralization	*)


TYPE
  narrator_rbPtr = POINTER TO narrator_rb ;
  mouth_rbPtr	 = POINTER TO mouth_rb    ;

  (* Standard Write request *)

  narrator_rb = RECORD
    message	: IOStdReq ;	(* Standard IORB		  *)
    rate	: CARDINAL ;	(* Speaking rate (words/minute)   *)
    pitch	: CARDINAL ;	(* Baseline pitch in Hertz	  *)
    mode	: CARDINAL ;	(* Pitch mode			  *)
    sex		: CARDINAL ;	(* Sex of voice			  *)
    ch_masks	: ADDRESS  ;	(* Pointer to audio alloc maps	  *)
    nm_masks	: CARDINAL ;	(* Number of audio alloc maps	  *)
    volume	: CARDINAL ;	(* Volume. 0 (off) thru 64	  *)
    sampfreq	: CARDINAL ;	(* Audio sampling freq		  *)
    mouths	: BOOLEAN  ;	(* If non-zero, generate mouths   *)
    chanmask	: SHORTCARD;	(* Which ch mask used (internal)  *)
    numchan	: SHORTCARD;	(* Num ch masks used (internal)   *)

    flags	: SHORTSET  ;	(* New feature flags		  *)
    F0enthusiasm: SHORTCARD ;	(* F0 excursion factor		  *)
    F0perturb	: SHORTCARD ;	(* Amount of F0 perturbation	  *)
    F1adj	: SHORTINT  ;	(* F1 adjustment in ±5% steps	  *)
    F2adj	: SHORTINT  ;	(* F2 adjustment in ±5% steps	  *)
    F3adj	: SHORTINT  ;	(* F3 adjustment in ±5% steps	  *)
    A1adj	: SHORTINT  ;	(* A1 adjustment in decibels	  *)
    A2adj	: SHORTINT  ;	(* A2 adjustment in decibels	  *)
    A3adj	: SHORTINT  ;	(* A3 adjustment in decibels	  *)
    articulate	: SHORTCARD ;	(* Transition time multiplier	  *)
    centralize	: SHORTCARD ;	(* Degree of vowel centralization *)
    centphon	: STRING    ;	(* Pointer to central ASCII phon  *)
    AVbias	: SHORTINT  ;	(* AV bias			  *)
    AFbias	: SHORTINT  ;	(* AF bias			  *)
    priority	: SHORTINT  ;	(* Priority while speaking	  *)
    pad1	: SHORTINT  ;	(* For alignment		  *)
  END ;

  (* Standard Read request *)

  mouth_rb = RECORD
    voice   : narrator_rb ; (* Speech IORB			*)
    width   : SHORTCARD   ; (* Width (returned value)		*)
    height  : SHORTCARD   ; (* Height (returned value)		*)
    shape   : SHORTCARD   ; (* Internal use, do not modify	*)
    sync    : SHORTCARD   ; (* Returned sync events		*)
  END ;

END Narrator.
