Three primary steps are required to open the narrator device: * Create a message port using createport(). reply messages from the device must be directed to a message port. * Create an extended I/O request structure of type narrator_rb. the narrator_rb structure is created by the createextio() function. * Open the narrator device. Call opendevice() passing the i/o request. struct MsgPort *VoiceMP; struct narrator_rb *VoiceIO; if (VoiceMP = CreatePort("speech_write",0)) if (VoiceIO = (struct narrator_rb *) CreateExtIO(VoiceMP,sizeof(struct narrator_rb)); if (OpenDevice("narrator.device", 0, VoiceIO, 0)) printf("narrator.device did not open\n"); When the narrator device is first opened, it initializes certain fields in the user's narrator_rb i/o request structure. in order to maintain backwards compatibility with older versions of the narrator device, a mechanism was needed for the device to ascertain whether it was being opened with a V37 or pre-V37 style I/O request structure. The pad field in the pre-V37 narrator_rb i/o request structure (which no one should have ever touched!) has been replaced by the flags field in the V37 narrator_rb structure, and is our path to upward compatibility. The device checks to see if a bit is set in this flags field. This bit must be set before opening the device if V37 or later features of the narrator device are to be used. There are two defined constants in the include file, NDB_NEWIORB and NDF_NEWIORB. NDB_NEWIORB specifies the bit which must be set in the flags field, NDF_NEWIORB is the field definition of the bit (1 << NDB_NEWIORB). Once the device is opened, the mouth_rb (read) i/o request structure can be set up. Each cmd_read request must be matched with an associated cmd_write request. this is necessary for the device to match the various sync events with a particular utterance. The read I/O request structure is easily set up as follows: * Create a read message port using the createport() function. * Allocate memory for the mouth_rb extended i/o request structure using allocmem(). * Copy the narrator_rb i/o request structure used to open the device into the voice field of the mouth_rb i/o request structure. this will set the fields necessary for the device to make the correct correspondence between read and write requests. * Copy the pointer to the read message port returned from createport() into the voice.message.io_Message.mn_ReplyPort field of the mouth_rb structure. The following code fragment, in conjunction with the opendevice() code fragment above, shows how to set up the mouth_rb structure: struct MsgPort *MouthMP; struct mouth_rb *MouthIO; if (MouthMP = CreatePort("narrator_read", 0)) if (!(MouthIO = (struct mouth_rb *) AllocMem(sizeof(struct mouth_rb),MEMF_PUBLIC|MEMF_CLEAR))) { /* Copy I/O request used in OpenDevice */ MouthIO->voice = *VoiceIO; /* Set port */ MouthIO->voice.message.io_Message.mn_ReplyPort=MouthMP; } else printf("AllocMem failed\n"); else printf("CreatePort failed\n");