home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / Mac / Speech.xs < prev    next >
Text File  |  1998-04-17  |  7KB  |  337 lines

  1. /* $Header: /home/neeri/MacCVS/MacPerl/perl/ext/Mac/Speech/Speech.xs,v 1.4 1998/04/07 01:03:15 neeri Exp $
  2.  *
  3.  *    Copyright (c) 1996 Matthias Neeracher
  4.  *
  5.  *    You may distribute under the terms of the Perl Artistic License,
  6.  *    as specified in the README file.
  7.  *
  8.  * $Log: Speech.xs,v $
  9.  * Revision 1.4  1998/04/07 01:03:15  neeri
  10.  * MacPerl 5.2.0r4b1
  11.  *
  12.  * Revision 1.3  1997/11/18 00:53:21  neeri
  13.  * MacPerl 5.1.5
  14.  *
  15.  * Revision 1.2  1997/08/08 16:39:30  neeri
  16.  * MacPerl 5.1.4b1 + time() fix
  17.  *
  18.  * Revision 1.1  1997/04/07 20:50:45  neeri
  19.  * Synchronized with MacPerl 5.1.4a1
  20.  *
  21.  */
  22.  
  23. #define MAC_CONTEXT
  24.  
  25. #include "EXTERN.h"
  26. #include "perl.h"
  27. #include "XSUB.h"
  28. #include <Types.h>
  29. #include <Memory.h>
  30. #include <Speech.h>
  31.  
  32. #ifndef __CFM68K__
  33. #include <FixMath.h>
  34. #else
  35. #define fixed1              ((Fixed) 0x00010000L)
  36. #define fract1              ((Fract) 0x40000000L)
  37. #define positiveInfinity    ((long)  0x7FFFFFFFL)
  38. #define negativeInfinity    ((long)  0x80000000L)
  39.  
  40. extern pascal long double Frac2X(Fract x) = 0xA845;
  41. extern pascal long double Fix2X(Fixed x) = 0xA843;
  42. extern pascal Fixed X2Fix(long double x) = 0xA844;
  43. extern pascal Fract X2Frac(long double x) = 0xA846;
  44. #endif
  45.  
  46. #ifdef __CFM68K__
  47.  
  48. #undef FOURWORDINLINE
  49. #define FOURWORDINLINE(w1,w2,w3,w4)  = {w1,w2,w3,w4}
  50.  
  51. extern pascal NumVersion SpeechManagerVersion(void)
  52.  FOURWORDINLINE(0x203C, 0x0000, 0x000C, 0xA800);
  53.  
  54. extern pascal OSErr MakeVoiceSpec(OSType creator, OSType id, VoiceSpec *voice)
  55.  FOURWORDINLINE(0x203C, 0x0604, 0x000C, 0xA800);
  56.  
  57. extern pascal OSErr CountVoices(short *numVoices)
  58.  FOURWORDINLINE(0x203C, 0x0108, 0x000C, 0xA800);
  59.  
  60. extern pascal OSErr GetIndVoice(short index, VoiceSpec *voice)
  61.  FOURWORDINLINE(0x203C, 0x030C, 0x000C, 0xA800);
  62.  
  63. extern pascal OSErr GetVoiceDescription(const VoiceSpec *voice, VoiceDescription *info, long infoLength)
  64.  FOURWORDINLINE(0x203C, 0x0610, 0x000C, 0xA800);
  65.  
  66. extern pascal OSErr GetVoiceInfo(const VoiceSpec *voice, OSType selector, void *voiceInfo)
  67.  FOURWORDINLINE(0x203C, 0x0614, 0x000C, 0xA800);
  68.  
  69. extern pascal OSErr NewSpeechChannel(VoiceSpec *voice, SpeechChannel *chan)
  70.  FOURWORDINLINE(0x203C, 0x0418, 0x000C, 0xA800);
  71.  
  72. extern pascal OSErr DisposeSpeechChannel(SpeechChannel chan)
  73.  FOURWORDINLINE(0x203C, 0x021C, 0x000C, 0xA800);
  74.  
  75. extern pascal OSErr SpeakString(ConstStr255Param s)
  76.  FOURWORDINLINE(0x203C, 0x0220, 0x000C, 0xA800);
  77.  
  78. extern pascal OSErr SpeakText(SpeechChannel chan, const void * textBuf, unsigned long textBytes)
  79.  FOURWORDINLINE(0x203C, 0x0624, 0x000C, 0xA800);
  80.  
  81. extern pascal OSErr SpeakBuffer(SpeechChannel chan, const void * textBuf, unsigned long textBytes, long controlFlags)
  82.  FOURWORDINLINE(0x203C, 0x0828, 0x000C, 0xA800);
  83.  
  84. extern pascal OSErr StopSpeech(SpeechChannel chan)
  85.  FOURWORDINLINE(0x203C, 0x022C, 0x000C, 0xA800);
  86.  
  87. extern pascal OSErr StopSpeechAt(SpeechChannel chan, long whereToStop)
  88.  FOURWORDINLINE(0x203C, 0x0430, 0x000C, 0xA800);
  89.  
  90. extern pascal OSErr PauseSpeechAt(SpeechChannel chan, long whereToPause)
  91.  FOURWORDINLINE(0x203C, 0x0434, 0x000C, 0xA800);
  92.  
  93. extern pascal OSErr ContinueSpeech(SpeechChannel chan)
  94.  FOURWORDINLINE(0x203C, 0x0238, 0x000C, 0xA800);
  95.  
  96. extern pascal short SpeechBusy(void)
  97.  FOURWORDINLINE(0x203C, 0x003C, 0x000C, 0xA800);
  98.  
  99. extern pascal short SpeechBusySystemWide(void)
  100.  FOURWORDINLINE(0x203C, 0x0040, 0x000C, 0xA800);
  101.  
  102. extern pascal OSErr SetSpeechRate(SpeechChannel chan, Fixed rate)
  103.  FOURWORDINLINE(0x203C, 0x0444, 0x000C, 0xA800);
  104.  
  105. extern pascal OSErr GetSpeechRate(SpeechChannel chan, Fixed *rate)
  106.  FOURWORDINLINE(0x203C, 0x0448, 0x000C, 0xA800);
  107.  
  108. extern pascal OSErr SetSpeechPitch(SpeechChannel chan, Fixed pitch)
  109.  FOURWORDINLINE(0x203C, 0x044C, 0x000C, 0xA800);
  110.  
  111. extern pascal OSErr GetSpeechPitch(SpeechChannel chan, Fixed *pitch)
  112.  FOURWORDINLINE(0x203C, 0x0450, 0x000C, 0xA800);
  113.  
  114. extern pascal OSErr SetSpeechInfo(SpeechChannel chan, OSType selector, const void *speechInfo)
  115.  FOURWORDINLINE(0x203C, 0x0654, 0x000C, 0xA800);
  116.  
  117. extern pascal OSErr GetSpeechInfo(SpeechChannel chan, OSType selector, void *speechInfo)
  118.  FOURWORDINLINE(0x203C, 0x0658, 0x000C, 0xA800);
  119.  
  120. extern pascal OSErr TextToPhonemes(SpeechChannel chan, const void * textBuf, unsigned long textBytes, Handle phonemeBuf, long *phonemeBytes)
  121.  FOURWORDINLINE(0x203C, 0x0A5C, 0x000C, 0xA800);
  122.  
  123. extern pascal OSErr UseDictionary(SpeechChannel chan, Handle dictionary)
  124.  FOURWORDINLINE(0x203C, 0x0460, 0x000C, 0xA800);
  125.  
  126. #endif
  127.  
  128. #define SpeechFail(error)   if (gLastMacOSErr = (error)) { XSRETURN_UNDEF; } else 0
  129.  
  130. MODULE = Mac::Speech    PACKAGE = Mac::Speech
  131.  
  132. =head2 Functions
  133.  
  134. =over 4
  135.  
  136. =item SpeechManagerVersion 
  137.  
  138. =cut
  139. NumVersion 
  140. SpeechManagerVersion()
  141.  
  142.  
  143. =item CountVoices 
  144.  
  145. =cut
  146. short
  147. CountVoices()
  148.     CODE:
  149.     SpeechFail(CountVoices(&RETVAL));
  150.     OUTPUT:
  151.     RETVAL
  152.  
  153.  
  154. =item GetIndVoice INDEX 
  155.  
  156. =cut
  157. VoiceSpec
  158. GetIndVoice(index)
  159.     short index
  160.     CODE:
  161.     SpeechFail(GetIndVoice(index, &RETVAL));
  162.     OUTPUT:
  163.     RETVAL
  164.     
  165.  
  166. =item GetVoiceDescription VOICE 
  167.  
  168. =cut
  169. VoiceDescription
  170. GetVoiceDescription(voice)
  171.     VoiceSpec &voice
  172.     CODE:
  173.     SpeechFail(GetVoiceDescription(&voice, &RETVAL, sizeof(RETVAL)));
  174.     OUTPUT:
  175.     RETVAL
  176.  
  177.  
  178. =item NewSpeechChannel VOICE 
  179.  
  180. =cut
  181. SpeechChannel
  182. NewSpeechChannel(voice)
  183.     VoiceSpec &voice
  184.     CODE:
  185.     SpeechFail(NewSpeechChannel(&voice, &RETVAL));
  186.     OUTPUT:
  187.     RETVAL
  188.  
  189.  
  190. =item DisposeSpeechChannel CHAN 
  191.  
  192. =cut
  193. MacOSRet
  194. DisposeSpeechChannel(chan)
  195.     SpeechChannel chan
  196.  
  197.  
  198. =item SpeakString S 
  199.  
  200. =cut
  201. MacOSRet
  202. SpeakString(s)
  203.     Str255 s;
  204.  
  205.  
  206. =item SpeakText CHAN, TEXT 
  207.  
  208. =cut
  209. MacOSRet
  210. SpeakText(chan, text)
  211.     SpeechChannel   chan
  212.     SV *            text
  213.     CODE:
  214.     {
  215.         void *  textPtr;
  216.         STRLEN  textSize;
  217.         
  218.         textPtr =   SvPV(text, textSize);
  219.         RETVAL  =   SpeakText(chan, textPtr, textSize);
  220.     }
  221.     OUTPUT:
  222.     RETVAL
  223.  
  224.  
  225. =item SpeakBuffer CHAN, TEXT, CONTROLFLAGS 
  226.  
  227. =cut
  228. MacOSRet
  229. SpeakBuffer(chan, text, controlFlags)
  230.     SpeechChannel   chan
  231.     SV *            text
  232.     long            controlFlags
  233.     CODE:
  234.     {
  235.         void *  textPtr;
  236.         STRLEN  textSize;
  237.         
  238.         textPtr =   SvPV(text, textSize);
  239.         RETVAL  =   SpeakBuffer(chan, textPtr, textSize, controlFlags);
  240.     }
  241.     OUTPUT:
  242.     RETVAL
  243.  
  244.  
  245. =item StopSpeech CHAN 
  246.  
  247. =cut
  248. MacOSRet
  249. StopSpeech(chan)
  250.     SpeechChannel chan
  251.  
  252.  
  253. =item StopSpeechAt CHAN, WHERETOSTOP 
  254.  
  255. =cut
  256. MacOSRet
  257. StopSpeechAt(chan, whereToStop)
  258.     SpeechChannel   chan
  259.     long            whereToStop
  260.  
  261.  
  262. =item PauseSpeechAt CHAN, WHERETOPAUSE 
  263.  
  264. =cut
  265. MacOSRet
  266. PauseSpeechAt(chan, whereToPause)
  267.     SpeechChannel   chan
  268.     long            whereToPause
  269.  
  270.  
  271. =item ContinueSpeech CHAN 
  272.  
  273. =cut
  274. MacOSRet
  275. ContinueSpeech(chan)
  276.     SpeechChannel chan
  277.  
  278.  
  279. =item SpeechBusy 
  280.  
  281. =cut
  282. int
  283. SpeechBusy()
  284.  
  285.  
  286. =item SpeechBusySystemWide 
  287.  
  288. =cut
  289. int
  290. SpeechBusySystemWide()
  291.  
  292.  
  293. =item SetSpeechRate CHAN, RATE 
  294.  
  295. =cut
  296. MacOSRet
  297. SetSpeechRate(chan, rate)
  298.     SpeechChannel   chan
  299.     Fixed           rate
  300.  
  301.  
  302. =item GetSpeechRate CHAN 
  303.  
  304. =cut
  305. Fixed
  306. GetSpeechRate(chan)
  307.     SpeechChannel   chan
  308.     CODE:
  309.     SpeechFail(GetSpeechRate(chan, &RETVAL));
  310.     OUTPUT:
  311.     RETVAL
  312.  
  313.  
  314. =item SetSpeechPitch CHAN, PITCH 
  315.  
  316. =cut
  317. MacOSRet
  318. SetSpeechPitch(chan, pitch)
  319.     SpeechChannel   chan
  320.     Fixed           pitch
  321.  
  322.  
  323. =item GetSpeechPitch CHAN 
  324.  
  325. =cut
  326. Fixed
  327. GetSpeechPitch(chan)
  328.     SpeechChannel   chan
  329.     CODE:
  330.     SpeechFail(GetSpeechPitch(chan, &RETVAL));
  331.     OUTPUT:
  332.     RETVAL
  333.  
  334. =back
  335.  
  336. =cut
  337.