Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 1 - Introduction to Sound on the Macintosh / Using Sound on Macintosh Computers


Legacy Documentclose button

Important: Inside Macintosh: Sound is deprecated as of Mac OS X v10.5. For new audio development in Mac OS X, use Core Audio. See the Audio page in the ADC Reference Library.

Checking For Speech Capabilities

Because the Speech Manager is not available in all system software versions, your application should always check for speech capabilities before attempting to use them. Listing 1-7 defines a function that determines whether the Speech Manager is available.

Listing 1-7 Checking for speech generation capabilities

FUNCTION MyHasSpeech: Boolean;
VAR
   myFeature:     LongInt;       {feature being tested}
   myErr:         OSErr;
BEGIN
   myErr := Gestalt(gestaltSpeechAttr, myFeature);
   IF myErr = noErr THEN         {test Speech Manager-present bit}
      MyHasSpeech := BTst(myFeature, gestaltSpeechMgrPresent)
   ELSE
      MyHasSpeech := FALSE;      {no speech features available}
END;
The MyHasSpeech function defined in Listing 1-7 uses the Gestalt function to determine whether the Speech Manager is available. The MyHasSpeech function tests the gestaltSpeechMgrPresent bit and returns TRUE if and only if the Speech Manager is present. If the Gestalt function cannot obtain the desired information and returns a result code other than noErr, the MyHasSpeech function assumes that the Speech Manager is not available and therefore returns FALSE.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996