SPBRecord
SPBPtr * inParamPtr; a pointer to a sound input parameter block
Boolean asynchFlag; TRUE=Record asynchronously You can use the SPBRecord function to record audio data directly from a sound input device into memory, either synchronously or asynchronously.
SPBRecord does not present the sound input dialog box to the user. inParamPtr SPBRecord accepts a sound input parameter block , SPB, to control the recording process. The following fields are relevant:
Æ 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
Æ bufferLength long 4 12 length of buffer
Æ bufferPtr long 4 16 address of buffer
Æ 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.
noErr (0) No error
siNoSoundInHardware (-220) No sound input hardware available
siBadSoundInDevice (-221) Invalid sound input device
siNoBufferSpecified (-222) No buffer specified
siDeviceBusyErr (-227) Sound input device is busy
Notes: SPBRecord starts recording into memory from a specified device. The sound data recorded is simply stored in the buffer indicated, so it is up to
your application to insert whatever headers are needed to play the sound
with the Sound Manager. The asynchFlag parameter specifies whether the recording occurs asynchronously.
SPBRecord accepts a sound input parameter block , SPB, to control the recording process. The inRefNum field of the parameter block should contain
the reference number of the device to record from. The count field contains
the number of bytes to record and the milliseconds field contains the
number of milliseconds to record. If one of these fields specifies a longer
recording time than the other, then the longer time is used and both fields
are updated to reflect the actual amount recorded.
The bufferPtr field points to the buffer to record into, and the
bufferLength field gives the length (in bytes) of that buffer. The recording
times given in the count and milliseconds fields are always truncated to the
size of this buffer, if necessary. If the bufferPtr field contains NULL, then
the count, milliseconds, and bufferLength fields are ignored, and the
bufferPtr is NULL, the audio data is not saved anywhere; this feature is
useful only if you want to do something in your interrupt routine and do not
want to save the audio data. If the recording is synchronous and bufferPtr is
NULL, SPBRecord returns the result code siNoBufferSpecified. The completion routine specified in the completionRoutine field is called
or when the prescribed limit is reached). The completion routine is called
only for asynchronous recording.
The interrupt routine specified in the interruptRoutine field is called by
asynchronous recording devices when their internal buffers are full.
You can set the userLong field to any value. The error field contains a value
greater than 0 while recording occurs. When recording terminates without
an error, the error field is set to 0. If an error occurs during the
recording, the error field will contain a value that is less than 0 and is of
Note: If more than one channel is being recorded, the samples are
interleaved into the buffer.