Inside Macintosh: Sound Manager
| Previous | Chapter contents | Chapter top | Section top | Next |
Important: Sound Input Manager 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.
The Sound Input Manager provides two high-level sound input functions, SndRecord and SndRecordToFile , for recording sound. These input routines are analogous to the two Sound Manager functions SndPlay and SndStartFilePlay . By using these high-level routines, you can be assured that your application presents a user interface that is consistent with that displayed by other applications doing sound input. Both SndRecord and SndRecordToFile attempt to record sound data from the sound input hardware currently selected in the Sound In control panel.
You can use the SndRecord function to record sound resources into memory.
FUNCTION SndRecord (filterProc: ProcPtr; corner: Point;
quality: OSType; VAR sndHandle:
Handle):
OSErr;
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.
The horizontal and vertical coordinates of the upper-left corner of the sound recording dialog box (in global coordinates).
The desired quality of the recorded sound.
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).
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.
Because the SndRecord function moves memory, you should not call it at interrupt time.
You can use SndRecordToFile to record sound data into a file.
FUNCTION SndRecordToFile (filterProc: ProcPtr; corner: Point;
quality: OSType;
fRefNum: Integer): OSErr;
A pointer to a function that determines how user actions in the sound recording dialog box are filtered.
The horizontal and vertical coordinates of the upper-left corner of the sound recording dialog box (in global coordinates).
The desired quality of the recorded sound, as described on [link] .
The file reference number of an open file to save the audio data in.
The SndRecordToFile function works just like SndRecord except that it stores the sound input data into a file. The resulting file is in either AIFF or AIFF-C format and contains the information necessary to play the file by using the Sound Manager's SndStartFilePlay function. The SndRecordToFile function is always called synchronously.
Your application must open the file specified in the fRefNum parameter before calling the SndRecordToFile function. Your application must close the file sometime after calling SndRecordToFile .
Because the SndRecordToFile function moves memory, you should not call it at interrupt time.
Inside Macintosh: Sound Manager
| Previous | Chapter contents | Chapter top | Section top | Next |
Important: Sound Input Manager 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.