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 Sound-Recording Equipment

Before allowing a user to record a sound, you must ensure that sound-recording hardware and software are installed. You can record sound through the microphone built into several Macintosh models, or through third-party sound input devices. Because low-level sound input device drivers handle communication between your application and the sound recording hardware, you do not need to know what type of microphone is available. Listing 1-3 defines a function that determines whether sound recording hardware is available.

Listing 1-3 Determining whether sound recording equipment is available

FUNCTION MyHasSoundInput: Boolean;
VAR
   myFeature:  LongInt;
   myErr:      OSErr;
BEGIN
   myErr := Gestalt(gestaltSoundAttr, myFeature);
   IF myErr = noErr THEN         {test sound input device bit}
      MyHasSoundInput := BTst(myFeature, gestaltHasSoundInputDevice)
   ELSE
      MyHasSoundInput := FALSE;  {no sound features available}
END;
The MyHasSoundInput function defined in Listing 1-3 uses the Gestalt function to determine whether sound input hardware is available and usable on the current Macintosh computer. MyHasSoundInput tests the gestaltHasSoundInputDevice bit and returns TRUE if you can record sounds. MyHasSoundInput returns FALSE if you cannot record sounds (either because no sound input device exists or because the Sound Input Manager is not available).

Note
For more information on the Gestalt function, see Inside Macintosh: Operating System Utilities.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996