Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 3 - Sound Input Manager / Sound Input Manager Reference
Sound Input Manager Routines / Recording Sounds


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.

SndRecord

You can use the SndRecord function to record sound resources into memory.

FUNCTION SndRecord (filterProc: ProcPtr; corner: Point; 
                     quality: OSType; VAR sndHandle: Handle): 
                     OSErr;
filterProc
A pointer to an event filter function that determines how user actions in the sound recording dialog box are filtered (similar to the filterProc parameter specified in a call to the ModalDialog procedure). By specifying your own filter function, you can override or add to the default actions of the items in the dialog box. If filterProc isn't NIL, SndRecord filters events by calling the function that filterProc points to.
corner
The horizontal and vertical coordinates of the upper-left corner of the sound recording dialog box (in global coordinates).
quality
The desired quality of the recorded sound.
sndHandle
On entry, a handle to some storage space or NIL. On exit, a handle to a valid sound resource (or unchanged, if the call did not execute successfully).
DESCRIPTION
The SndRecord function records sound into memory. The recorded data has the structure of a format 1 'snd ' resource and can later be played using the SndPlay function or can be stored as a resource. SndRecord displays a sound recording dialog box and is always called synchronously. Controls in the dialog box allow the user to start, stop, pause, and resume sound recording, as well as to play back the recorded sound. The dialog box also lists the remaining recording time and the current microphone sound level.

The quality parameter defines the desired quality of the recorded sound. Currently, three values are recognized for the quality parameter:

CONST
   siBestQuality        = 'best';   {the best quality available}
   siBetterQuality      = 'betr';   {a quality better than good}
   siGoodQuality        = 'good';   {a good quality}
The precise meanings of these parameters are defined by the sound input device driver. For Apple-supplied drivers, this parameter determines whether the recorded sound is to be compressed, and if so, whether at a 6:1 or a 3:1 ratio. The quality siBestQuality does not compress the sound and provides the best quality output, but at the expense of increased memory use. The quality siBetterQuality is suitable for most nonvoice recording, and siGoodQuality is suitable for voice recording.

The sndHandle parameter is a handle to some storage space. If the handle is NIL, the Sound Input Manager allocates a handle of the largest amount of space that it can find in your application's heap and returns this handle in the sndHandle parameter. The Sound Input Manager resizes the handle when the user clicks the Save button in the sound recording dialog box. If the sndHandle parameter passed to SndRecord is not NIL, the Sound Input Manager simply stores the recorded data in the location specified by that handle.

SPECIAL CONSIDERATIONS
Because the SndRecord function moves memory, you should not call it at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for the SndRecord function are
Trap macroSelector
_SoundDispatch$08040014

RESULT CODES
noErr0No error
userCanceledErr-128User canceled the operation
siBadSoundInDevice-221Invalid sound input device
siUnknownQuality-232Unknown quality
SEE ALSO
See the chapter "Dialog Manager" in Inside Macintosh: Macintosh Toolbox Essentials for a complete description of event filter functions.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996