Carbon


SPBRecordToFile

Header: Sound.h Carbon status: Unsupported

Records audio data into a file, either synchronously or asynchronously.

OSErr SPBRecordToFile (
    SInt16 fRefNum, 
     inParamPtr, 
    Boolean asynchFlag
);
Parameter descriptions
fRefNum

The file reference number of an open file in which to place the recorded sound data.

inParamPtr

A pointer to a sound input parameter block.

asynchFlag

A Boolean value that specifies whether the recording occurs asynchronously (TRUE) or synchronously (FALSE).

function result

A result code. The value that the error field of the parameter block contains when recording finishes.

DISCUSSION

The relevant fields of the sound input parameter block are:

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 two’s-complement format. If you don’t 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 function’s 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.

SPECIAL CONSIDERATIONS

Because the SPBRecordToFile function moves or purges memory, you should not call it at interrupt time.

AVAILABILITY

Not supported in Carbon. Not available in Carbon.

CARBON NOTES

QuickTime provides a more flexible means of recording sound files.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)