![]() |
SPBRecord |
||||
Header: | Sound.h | Carbon status: | Supported | |
Records audio data into memory, either synchronously or asynchronously.
OSErr SPBRecord ( inParamPtr, Boolean asynchFlag );
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.
You specify values and receive return values in the sound input parameter block. 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, this field indicates 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, this field indicates the number of milliseconds actually recorded. A value of type LongInt.
On input, the number of bytes in the buffer specified by the bufferPtr parameter. If this buffer length is too small to contain the amount of sampled-sound data specified in the count and milliseconds fields, then recording time is truncated so that the sampled-sound data fits in the buffer. A value of type LongInt.
On input, a pointer to the buffer for the sampled-sound data, or NULL if you wish to record sampled-sound data without saving it. On exit, this buffer contains the sampled-sound data, which is interleaved for stereo sound on a sample basis (or on a packet basis if the data is compressed). This buffer contains only sampled-sound data, so if you need a sampled sound header, you should set that up in a buffer before calling SPBRecord and then record into the buffer following the sound header. A value of type Ptr.
On input, a pointer to a completion function. This function is called when the recording terminates (either after you call the SPBStopRecording function or when the prescribed limit is reached). The completion function is called only for asynchronous recording. A value of type ProcPtr.
On input, a pointer to an interrupt function. The interrupt function specified in the interruptRoutine field is called by asynchronous recording devices when their internal buffers are full. 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 return, a value greater than 0 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 SPBRecord. A value of type LongInt.
The SPBRecord function starts recording into memory from a device specified in a sound input parameter block. The sound data recorded is stored in the buffer specified by the bufferPtr and bufferLength fields of the parameter block. Recording lasts the longer of the times specified by the count and milliseconds fields of the parameter block, or until the buffer is filled. Recording is asynchronous if the asynchFlag parameter is TRUE and the specified sound input device supports asynchronous recording.
If the bufferPtr field of the parameter block contains NULL, then the count, milliseconds, and bufferLength fields are ignored, and the recording continues indefinitely until you call the SPBStopRecording function. In this case, the audio data is not saved anywhere; this feature is useful only if you want to do something in your interrupt function and do not want to save the audio data. However, if the recording is synchronous and bufferPtr is NULL, SPBRecord returns the result code siNoBufferSpecified.
This low-level function does not display the sound recording dialog box to the user.
You can call the SPBRecord function at interrupt time.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)