Previous Book Contents Book Index Next

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


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.

Summary of Sound

Pascal Summary

Constants

CONST
   {Gestalt sound attributes selector and response bits}
   gestaltSoundAttr           = 'snd ';{sound attributes selector}
   gestaltStereoCapability    = 0;     {built-in hw can play stereo sounds}
   gestaltStereoMixing        = 1;     {built-in hw mixes stereo to mono}
   gestaltSoundIOMgrPresent   = 3;     {sound input routines available}
   gestaltBuiltInSoundInput   = 4;     {built-in input hw available}
   gestaltHasSoundInputDevice = 5;     {sound input device available}
   gestaltPlayAndRecord       = 6;     {built-in hw can play while recording}
   gestalt16BitSoundIO        = 7;     {built-in hw can handle 16-bit data}
   gestaltStereoInput         = 8;     {built-in hw can record stereo sounds}
   gestaltLineLevelInput      = 9;     {built-in input hw needs line level}
   gestaltSndPlayDoubleBuffer = 10;    {play from disk routines available}
   gestaltMultiChannels       = 11;    {multiple channels of sound supported}
   gestalt16BitAudioSupport   = 12;    {16-bit audio data supported}
   
   {Gestalt selector and response bits for speech attributes}
   gestaltSpeechAttr          = 'ttsc';{speech attributes selector}
   gestaltSpeechMgrPresent    = 0;     {Speech Manager is present}
   
   {recording qualities}
   siBestQuality           = 'best';   {the best quality available}
   siBetterQuality         = 'betr';   {a quality better than good}
   siGoodQuality           = 'good';   {a good quality}

Routines

Playing Sounds

PROCEDURE	SysBeep		(duration: Integer);
FUNCTION	SndPlay		(chan: SndChannelPtr; sndHdl: Handle; 
				async: Boolean): OSErr;
FUNCTION	SndStartFilePlay(chan: SndChannelPtr; fRefNum: Integer; 
				resNum: Integer; bufferSize: LongInt; 
				theBuffer: Ptr; 
				theSelection: AudioSelectionPtr; 
				theCompletion: ProcPtr; async: Boolean): OSErr;

Recording Sounds

FUNCTION	SndRecord	(filterProc: ProcPtr; corner: Point; 
				quality: OSType; VAR sndHandle: Handle): OSErr;
FUNCTION	SndRecordToFile	(filterProc: ProcPtr; corner: Point;
				quality: OSType; fRefNum: Integer): OSErr;

Generating and Stopping Speech

FUNCTION SpeakString(s: Str255): OSErr;
FUNCTION SpeechBusy: Integer;

C Summary

Constants

/*Gestalt sound attributes selector and response bits*/
#define gestaltSoundAttr    'snd '  /*sound attributes selector*/
enum {
   gestaltStereoCapability    = 0,  /*built-in hw can play stereo sounds*/
   gestaltStereoMixing        = 1,  /*built-in hw mixes stereo to mono*/
   gestaltSoundIOMgrPresent   = 3,  /*sound input routines available*/
   gestaltBuiltInSoundInput   = 4,  /*built-in input hw available*/
   gestaltHasSoundInputDevice = 5,  /*sound input device available*/
   gestaltPlayAndRecord       = 6,  /*built-in hw can play while recording*/
   gestalt16BitSoundIO        = 7,  /*built-in hw can handle 16-bit data*/
   gestaltStereoInput         = 8,  /*built-in hw can record stereo sounds*/
   gestaltLineLevelInput      = 9,  /*built-in input hw needs line level*/
   gestaltSndPlayDoubleBuffer = 10, /*play from disk routines available*/
   gestaltMultiChannels       = 11, /*multiple channels of sound supported*/
   gestalt16BitAudioSupport   = 12  /*16-bit audio data supported*/
};
/*Gestalt selector and response bits for speech attributes*/
#define gestaltSpeechAttr  'ttsc'   /*speech attributes selector*/
enum {
   gestaltSpeechMgrPresent    = 0   /*Speech Manager is present*/
};
/*recording qualities*/
#define siBestQuality         'best'   /*the best quality available*/
#define siBetterQuality       'betr'   /*a quality better than good*/
#define siGoodQuality         'good'   /*a good quality*/

Routines

Playing Sounds

pascal	void		SysBeep(short duration);
pascal	OSErr		SndPlay(SndChannelPtr chan, Handle sndHdl, 
			Boolean async);
pascal	OSErr		SndStartFilePlay
			(SndChannelPtr chan, short fRefNum,
			short resNum, long bufferSize, void *theBuffer,
			AudioSelectionPtr theSelection,
			FilePlayCompletionProcPtr theCompletion, Boolean async);

Recording Sounds

pascal	OSErr		SndRecord(ModalFilterProcPtr filterProc, Point corner,
			OSType quality, Handle *sndHandle);
pascal	OSErr		SndRecordToFile
			(ModalFilterProcPtr filterProc, Point corner,
			OSType quality, short fRefNum);

Generating and Stopping Speech

pascal	OSErr		SpeakString(StringPtr s);
pascal	short		SpeechBusy(void);

Result Codes
noErr0No error
userCanceledErr-128User canceled the operation
noHardwareErr-200Required sound hardware not available
notEnoughHardwareErr-201Insufficient hardware available
queueFull-203No room in the queue
resProblem-204Problem loading the resource
badChannel-205Channel is corrupt or unusable
badFormat-206Resource is corrupt or unusable
notEnoughBufferSpace-207Insufficient memory available
badFileFormat-208File is corrupt or unusable, or not AIFF or AIFF-C
channelBusy-209Channel is busy
buffersTooSmall-210Buffer is too small
siBadSoundInDevice-221Invalid sound input device
siInvalidCompression-223Invalid compression type
siUnknownQuality-232Unknown quality
synthOpenFailed-241Could not open another speech synthesizer channel


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996