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
TheSPBRecordandSPBRecordToFilefunctions 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-levelSndRecordandSndRecordToFilefunctions, the operation of sound input parameter blocks is transparent to your application. A sound input parameter block is defined by theSPBdata 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
SPBOpenDevicefunction) 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
millisecondsfield, then themillisecondsfield 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
countfield, then thecountfield is ignored on input.bufferLength- The length of the buffer into which recorded sound data is placed. The recording time specified by the
countormillisecondsfield 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, andbufferLengthfields are ignored and the recording will continue indefinitely until theSPBStopRecordingfunction is called. However, the data is not stored anywhere, so setting this field toNILis 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
SPBStopRecordingfunction or when the limit specified by thecountormillisecondsfield is reached. The completion routine executes only ifSPBRecordis 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
bufferPtrparameter. The interrupt routine executes only ifSPBRecordis 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.