SPBBytesToMilliSeconds
You can use the SPBBytesToMilliSeconds function to determine the maximum duration of a recording that can fit in a buffer of a certain size.
FUNCTION SPBBytesToMilliSeconds (inRefNum: LongInt;
VAR byteCount: LongInt): OSErr;
inRefNum
- The device reference number of the sound input device, as obtained from the
SPBOpenDevice function.
byteCount
- On entry, a value in bytes. On exit, the number of milliseconds of recording on the device specified by the
inRefNum parameter that would be necessary to fill a buffer of such a size.
DESCRIPTION
The SPBBytesToMilliSeconds function reports how many milliseconds of audio data can be recorded in a buffer that is byteCount bytes long, given the input device's current sample rate, sample size, number of channels, and compression factor.
SPECIAL CONSIDERATIONS
You can call the SPBBytesToMilliSeconds function at interrupt time.
ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for the SPBBytesToMilliSeconds function are
| Trap macro | Selector |
| _SoundDispatch | $04440014 |
RESULT CODES
| noErr | 0 | No error |
| siBadSoundInDevice | -221 | Invalid sound input device |