![]() |
SPBRecordToFile |
||||
Header: | Sound.h | Carbon status: | Unsupported | |
Records audio data into a file, either synchronously or asynchronously.
OSErr SPBRecordToFile ( SInt16 fRefNum, inParamPtr, Boolean asynchFlag );
The file reference number of an open file in which to place the recorded sound data.
A pointer to a sound input parameter block.
A Boolean value that specifies whether the recording occurs asynchronously (TRUE) or synchronously (FALSE).
A result code. The value that the error field of the parameter block contains when recording finishes.
The relevant fields of the sound input parameter block are:
On input, the device reference number of the sound input device, as obtained from the SPBOpenDevice function. A value of type LongInt.
On input, the number of bytes to record. If this field indicates a longer recording time than the milliseconds field, then the milliseconds field is ignored. On output, the number of bytes actually recorded. A value of type LongInt.
On input, the number of milliseconds to record. If this field indicates a longer recording time than the count field, then the count field is ignored. On output, the number of milliseconds actually recorded. A value of type LongInt.
On input, a pointer to a completion function. This function is called when the recording terminates (after you call the SPBStopRecording function, when the prescribed limit is reached, or after an error occurs). The completion function is called only for asynchronous recording. A value of type ProcPtr.
Unused. You should set this field to NULL before calling SPBRecordToFile. A value of type ProcPtr.
On input, a long integer that your application can use to pass data to your applications completion or interrupt functions. A value of type LongInt.
On exit, the error that occurred during recording. This field contains the number 1 while recording unless an error occurs, in which case it contains a value less than 0 that indicates an operating system error. Your application can poll this field to check on the status of an asynchronous recording. If recording terminates without an error, this field contains 0. A value of type OSErr.
Reserved. You should set this field to 0 before calling the SPBRecordToFile function.
The SPBRecordToFile function starts recording from the specified device into a file. The sound data recorded is simply stored in the file, so it is up to your application to insert whatever headers are needed to play the sound with the Sound Manager. Your application must open the file specified by the fRefNum parameter with write access before calling SPBRecordToFile, and it must eventually close that file.
The fields in the parameter block specified by the unprompted parameter are identical to the fields in the parameter block passed to the SPBRecord function, except that the bufferLength and bufferPtr fields are not used. The interruptfunctionfield is ignored by SPBRecordToFile because SPBRecordToFile copies data returned by the sound input device driver to disk during the sound input interrupt routine, but you should initialize this field to NULL.
The SPBRecordToFile function writes samples to disk in the same format that they are read in from the sound input device. If compression is enabled, then the samples written to the file are compressed. Multiple channels of sound are interleaved on a sample basis (or, for compressed sound data, on a packet basis). When you are recording 8-bit audio data to an AIFF file, you must set the siTwosComplementOnOff flag to so that the data is stored on disk in the twos-complement format. If you dont store the data in this format, it sounds distorted when you play it back.
If any errors occur during the file writing process, recording is suspended. All File Manager errors are returned through the functions return value if the function is called synchronously. If the function is called asynchronously and the completion function is not NULL, the completion function is called and is passed a single parameter on the stack that points to the sound input parameter block; any errors are returned in the error field of the sound input parameter block.
This low-level function does not display the sound recording dialog box to the user.
Because the SPBRecordToFile function moves or purges memory, you should not call it at interrupt time.
Not supported in Carbon. Not available in Carbon.
QuickTime provides a more flexible means of recording sound files.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)