home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / c / rkrm / narrator / speak_narrator.c < prev   
C/C++ Source or Header  |  1992-09-03  |  4KB  |  126 lines

  1. /*
  2.  * Copyright (c) 1992 Commodore-Amiga, Inc.
  3.  * 
  4.  * This example is provided in electronic form by Commodore-Amiga, Inc. for 
  5.  * use with the "Amiga ROM Kernel Reference Manual: Devices", 3rd Edition, 
  6.  * published by Addison-Wesley (ISBN 0-201-56775-X).
  7.  * 
  8.  * The "Amiga ROM Kernel Reference Manual: Devices" contains additional 
  9.  * information on the correct usage of the techniques and operating system 
  10.  * functions presented in these examples.  The source and executable code 
  11.  * of these examples may only be distributed in free electronic form, via 
  12.  * bulletin board or as part of a fully non-commercial and freely 
  13.  * redistributable diskette.  Both the source and executable code (including 
  14.  * comments) must be included, without modification, in any copy.  This 
  15.  * example may not be published in printed form or distributed with any
  16.  * commercial product.  However, the programming techniques and support
  17.  * routines set forth in these examples may be used in the development
  18.  * of original executable software products for Commodore Amiga computers.
  19.  * 
  20.  * All other rights reserved.
  21.  * 
  22.  * This example is provided "as-is" and is subject to change; no
  23.  * warranties are made.  All use is at your own risk. No liability or
  24.  * responsibility is assumed.
  25.  *
  26.  ***************************************************************************
  27.  *
  28.  * Speak_Narrator.c
  29.  *
  30.  * This example program sends a string of phonetic text to the narrator
  31.  * device twice, changing some of the characteristics the second time.
  32.  *
  33.  * Compile with SAS C 5.10  lc -b1 -cfistq -v -y -L
  34.  *
  35.  * Requires Kickstart V37 or greater.
  36.  */
  37.  
  38. #include <exec/types.h>
  39. #include <exec/exec.h>
  40. #include <exec/libraries.h>
  41. #include <dos/dos.h>
  42. #include <devices/narrator.h>
  43.  
  44.  
  45. #include <clib/exec_protos.h>
  46. #include <clib/alib_protos.h>
  47. #include <clib/dos_protos.h>
  48.  
  49. #include <string.h>
  50. #include <stdio.h>
  51.  
  52. #ifdef LATTICE
  53. int CXBRK(void) { return(0); }    /* Disable SAS CTRL/C handling */
  54. int chkabort(void) { return(0); } /* really */
  55. #endif
  56.  
  57. extern struct Library *SysBase;   /* Used to check the OS the version number */
  58.  
  59. void main(void)
  60. {
  61. struct  MsgPort     *VoiceMP;
  62. struct  narrator_rb *VoiceIO;
  63. UBYTE   *PhoneticText    = "DHIHS IHZ AHMIY5GAH SPIY5KIHNX.";
  64. BYTE    audio_chan[4]   = {3, 5, 10, 12};
  65.  
  66.    /* Check the version number of the operating system */
  67. if(SysBase->lib_Version>=36)
  68.    {
  69.       /* Create the message port */
  70.    if (VoiceMP=CreateMsgPort())
  71.       {
  72.          /* Create the IORequest */
  73.       if (VoiceIO = CreateIORequest(VoiceMP,sizeof(struct narrator_rb)))
  74.          {
  75.          /*   Set the NEWIORB bit in the flags field to use the new fields */
  76.          VoiceIO->flags = NDF_NEWIORB;
  77.  
  78.             /* Open the narrator device */
  79.          if (OpenDevice("narrator.device",0,(struct IORequest *)VoiceIO,0L))
  80.  
  81.             /* Inform user that it could not be opened */
  82.             printf("Error: narrator.device did not open\n");
  83.  
  84.          else
  85.             {
  86.              /* Speak the string using the default parameters */
  87.              VoiceIO->ch_masks = &audio_chan[0];
  88.              VoiceIO->nm_masks = sizeof(audio_chan);
  89.              VoiceIO->message.io_Command = CMD_WRITE;
  90.              VoiceIO->message.io_Data = PhoneticText;
  91.              VoiceIO->message.io_Length = strlen(PhoneticText);
  92.              DoIO(VoiceIO);
  93.  
  94.              /* Now change some of the characteristics:
  95.               *   Raise the first formant, lower the third formant,
  96.               *       and move 50% of the way towards AO.
  97.               * and speak it again.
  98.               */
  99.  
  100.             VoiceIO->A1adj = -32;        /* Shut off first formant  */
  101.             VoiceIO->A3adj =  11;        /* Raise the third formant */
  102.             VoiceIO->centralize = 50;        /* Move 50% of the way        */
  103.             VoiceIO->centphon = "AO";        /* towards AO           */
  104.             DoIO(VoiceIO);
  105.  
  106.             /* Close the narrator device */
  107.             CloseDevice((struct IORequest *)VoiceIO);
  108.             }
  109.          /* Delete the IORequest */
  110.          DeleteIORequest(VoiceIO);
  111.          }
  112.       else
  113.          /* Inform user that the IORequest could be created */
  114.          printf("Error: Could not create IORequest\n");
  115.  
  116.       /* Delete the message port */
  117.       DeleteMsgPort(VoiceMP);
  118.       }
  119.    else
  120.       /* Inform user that the message port could not be created */
  121.       printf("Error: Could not create message port\n");
  122.    }
  123. else
  124.    printf("Error: Release 2 (V36) or a later version of the OS required.\n");
  125. }
  126.