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.
SPBOpenDevice
You can use theSPBOpenDevice
function to open a sound input device.
FUNCTION SPBOpenDevice (deviceName: Str255; permission: Integer; VAR inRefNum: LongInt): OSErr;
deviceName
- The name of the sound input device to open, or the empty string if the default sound input device is to be opened.
permission
- A flag that indicates whether subsequent operations with that device are to be read/write or read-only.
inRefNum
- On exit, if the function is successful, a device reference number for the open sound input device.
DESCRIPTION
TheSPBOpenDevice
function attempts to open a sound input device having the name indicated by thedeviceName
parameter. IfSPBOpenDevice
succeeds, it returns a device reference number in theinRefNum
parameter. Thepermission
parameter indicates whether subsequent operations with that device are to be read/write or read-only. If the device is not already in use, read/write permission is granted; otherwise, only read-only operations are allowed. To make any recording requests or to call theSPBSetDeviceInfo
function, read/write permission must be available. Use these constants to request the appropriate permission:
CONST siReadPermission = 0; {open device for reading} siWritePermission = 1; {open device for reading/writing}You can request that the current default sound input device be opened by passing either a zero-length string or aNIL
string as thedeviceName
parameter. If only one sound input device is installed, that device is used. Generally you should open the default device unless you specifically want to use some other device. You can get a list of the available devices by calling theSPBGetIndexedDevice
function.SPECIAL CONSIDERATIONS
Because theSPBOpenDevice
function allocates memory, you should not call it at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theSPBOpenDevice
function are
Trap macro Selector _SoundDispatch $05180014 RESULT CODES
noErr 0 No error permErr -54 Device already open for writing siBadDeviceName -228 Invalid device name