SPBRecordToFile
SPBRecordToFile Record audio data into a file
#include <SoundInput.h> Sound Manager
OSErr SPBRecordToFile( fRefNum, inParamPtr, asynchFlag);
short fRefNum; a valid reference number for an open file
SPBPtr * inParamPtr; a pointer to a sound input parameter block
Boolean asynchFlag; TRUE=Record asynchronously
returns Error Code; 0=no error
The SPBRecordToFile function starts recording from a 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.
fRefNum must contain a valid reference number for an open file. (In other
words, your application must first open the file with write access,
pass the returned file reference number to SPBRecordToFile, and
eventually close the file.)
inParamPtr SPBRecordToFile accepts a sound input parameter block , SPB,
to control the recording process. The following fields are relevant:
Out-In Name Type Size Offset Description
Æ inRefNum long 4 0 input device reference number
´ count long 4 4 number of bytes to record
´ milliseconds long 4 8 number of milliseconds to record
Æ completionRoutine long 4 20 pointer to completion routine
Æ interruptRoutine long 4 24 pointer to interrupt routine
Æ userLong long 4 28 for application's use
¨ error short 2 32 error returned after recording
Æ unused1 long 4 36 reserved
asynchFlag specifies whether the recording occurs asynchronously.
Returns: an operating system Error Code.
noErr (0) No error
permErr (-54) Attempt to open locked file for writing
siNoSoundInHardware (-220) No sound input hardware available
siBadSoundInDevice (-221) Invalid sound input device
siHardDriveTooSlow (-224) Hard drive too slow to record

Notes: The fields in the parameter block specified by the inParamPtr parameter
are identical to the fields in the parameter block passed to SPBRecord,
except that the bufferLength and bufferPtr fields are not used. The
interruptRoutine field is ignored by SPBRecordToFile, but you should
initialize it to NULL.
SPBRecordToFile 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.
If any errors occur during file writes, recording is suspended. All
File Manager errors are returned through the function's return value if
the routine is called synchronously. If the routine is called asynchronously
and the completion routine is not NULL, the completion routine is called and
is passed a single parameter on the stack that points to the sound input
parameter block , SPB; any errors are returned in the error field of the
sound input parameter block. The error field in the sound input parameter
block is 1 while input is active, 0 when input is complete, and less than 0 if
an error occurs.