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 theSndRecord
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 theModalDialog
procedure). By specifying your own filter function, you can override or add to the default actions of the items in the dialog box. IffilterProc
isn'tNIL
,SndRecord
filters events by calling the function thatfilterProc
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
TheSndRecord
function records sound into memory. The recorded data has the structure of a format 1'snd '
resource and can later be played using theSndPlay
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 thequality
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 qualitysiBestQuality
does not compress the sound and provides the best quality output, but at the expense of increased memory use. The qualitysiBetterQuality
is suitable for most nonvoice recording, andsiGoodQuality
is suitable for voice recording.The
sndHandle
parameter is a handle to some storage space. If the handle isNIL
, 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 thesndHandle
parameter. The Sound Input Manager resizes the handle when the user clicks the Save button in the sound recording dialog box. If thesndHandle
parameter passed toSndRecord
is notNIL
, the Sound Input Manager simply stores the recorded data in the location specified by that handle.SPECIAL CONSIDERATIONS
Because theSndRecord
function moves memory, you should not call it at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theSndRecord
function are
Trap macro Selector _SoundDispatch $08040014 RESULT CODES
noErr 0 No error userCanceledErr -128 User canceled the operation siBadSoundInDevice -221 Invalid sound input device siUnknownQuality -232 Unknown quality SEE ALSO
For an example of how to record a sound resource using theSndRecord
function, see "Recording a Sound Resource" on page 1-28. See the chapter "Dialog Manager" in Inside Macintosh: Macintosh Toolbox Essentials for a complete description of event filter functions.