Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 3 - Sound Input Manager / Sound Input Manager Reference
Sound Input Manager Routines / Converting Between Milliseconds and Bytes


Legacy Documentclose button

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.

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 macroSelector
_SoundDispatch$04440014

RESULT CODES
noErr0No error
siBadSoundInDevice-221Invalid sound input device

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996