Important: Inside Macintosh: Sound 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.
Sound Input Parameter Blocks
TheSPBRecord
andSPBRecordToFile
functions require a pointer to a sound input parameter block that defines characteristics of the recording. If you define a sound input completion routine or a sound input interrupt routine, your routine receives a pointer to a sound input parameter block. If you are using only the Sound Input Manager's high-levelSndRecord
andSndRecordToFile
functions, the operation of sound input parameter blocks is transparent to your application. A sound input parameter block is defined by theSPB
data type.
TYPE SPB = RECORD inRefNum: LongInt; {reference number of input device} count: LongInt; {number of bytes to record} milliseconds: LongInt; {number of milliseconds to record} bufferLength: LongInt; {length of buffer to record into} bufferPtr: Ptr; {pointer to buffer to record into} completionRoutine: ProcPtr; {pointer to a completion routine} interruptRoutine: ProcPtr; {pointer to an interrupt routine} userLong: LongInt; {for application's use} error: OSErr; {error returned after recording} unused1: LongInt; {reserved} END;
Field Description
inRefNum
- The reference number of the sound input device (as received from the
SPBOpenDevice
function) from which the recording is to occur.count
- On input, the number of bytes to record. On output, the number of bytes actually recorded. If this field specifies a longer recording time than the
milliseconds
field, then themilliseconds
field is ignored on input.milliseconds
- On input, the number of milliseconds to record. On output, the number of milliseconds actually recorded. If this field specifies a longer recording time than the
count
field, then thecount
field is ignored on input.bufferLength
- The length of the buffer into which recorded sound data is placed. The recording time specified by the
count
ormilliseconds
field is truncated to fit into this length, if necessary.bufferPtr
- A pointer to the buffer into which recorded data is placed. If this field is
NIL
, then thecount
,milliseconds
, andbufferLength
fields are ignored and the recording will continue indefinitely until theSPBStopRecording
function is called. However, the data is not stored anywhere, so setting this field toNIL
is useful only if you want to do something in a sound input interrupt routine but do not want to save the recorded sound.completionRoutine
- A pointer to a completion routine that is called when the recording terminates as a result of your calling the
SPBStopRecording
function or when the limit specified by thecount
ormilliseconds
field is reached. The completion routine executes only ifSPBRecord
is called asynchronously and therefore is called at interrupt time.interruptRoutine
- A pointer to a routine that is called by asynchronous recording devices when their internal buffers are full. You can define a sound input interrupt routine to modify uncompressed sound samples before they are placed into the buffer specified in the
bufferPtr
parameter. The interrupt routine executes only ifSPBRecord
is called asynchronously and therefore is called at interrupt time.userLong
- A long integer available for the application's own use. You can use this field, for instance, to pass a handle to an application-defined structure to the completion routine or to the interrupt routine.
error
- On exit, the error that occurred during recording. This field contains 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.
unused1
- Reserved for use by Apple. You should always initialize this field to 0.