BASS_ASIO_Init

Initializes an ASIO device/driver.

BOOL BASS_ASIO_Init(
    int device,
    DWORD flags
);

Parameters

deviceThe device to use... 0 = first device, -1 = first available device. BASS_ASIO_GetDeviceInfo can be used to enumerate the available devices.
flagsAny combination of these flags.
BASS_ASIO_ALLINPUTSEnable all input channels in the ASIO driver when starting, so that they can be reconfigured without restarting. The BASS_ASIO_JOINORDER flag cannot be used together with this flag.
BASS_ASIO_ALLOUTPUTSEnable all output channels in the ASIO driver when starting, so that they can be reconfigured without restarting. The BASS_ASIO_JOINORDER flag cannot be used together with this flag.
BASS_ASIO_PRELEVELSPre-calculate output channel levels when data is written to the ASIO driver's buffers, to avoid BASS_ASIO_ChannelGetLevel having to access the buffers. This is needed when the ASIO driver overwrites/clears the buffers. BASSASIO will try to automatically detect when pre-calculating is needed, but this flag be can used to force it. Input channels are unaffected.
BASS_ASIO_JOINORDERPlace joined channels in the order in which BASS_ASIO_ChannelJoin was called to join them, else place them in numerically ascending order.
BASS_ASIO_THREADHost the driver in a dedicated thread, else the current thread.

Return value

If the device was successfully initialized, TRUE is returned, else FALSE is returned. Use BASS_ASIO_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_DEVICEThe device number specified is invalid.
BASS_ERROR_ALREADYThe device has already been initialized. You must call BASS_ASIO_Free before you can initialize it again.
BASS_ERROR_ILLPARAMThe BASS_ASIO_JOINORDER flag cannot be combined with the BASS_ASIO_ALLINPUTS or BASS_ASIO_ALLOUTPUTS flag.
BASS_ERROR_DRIVERThe driver could not be initialized.

Remarks

This function must be successfully called before any input or output can be performed. When the first available device is initialized, BASS_ASIO_GetDevice can be used afterwards to find out which device that is.

The ASIO driver is accessed via a COM object using the single-threaded apartment model, which means that requests to the driver go through the thread that initialized it, so the thread needs to exist as long as the driver remains initialized. The thread should also have a message queue. If device initializing and releasing from multiple threads is required, or the application does not have a message queue (eg. a console application), then the BASS_ASIO_THREAD flag can be used to have BASSASIO create a dedicated thread to host the ASIO driver.

A window handle can be passed to the ASIO driver by first calling BASS_ASIO_SetWindow.

Simultaneously using multiple devices is supported in the BASSASIO API via a context switching system - instead of there being an extra "device" parameter in the function calls, the device to be used is set prior to calling the functions. BASS_ASIO_SetDevice is used to switch the current device. When successful, BASS_ASIO_Init automatically sets the current thread's device to the one that was just initialized.

See also

BASS_ASIO_ControlPanel, BASS_ASIO_Free, BASS_ASIO_GetDeviceInfo, BASS_ASIO_GetInfo, BASS_ASIO_ChannelEnable, BASS_ASIO_SetDSD, BASS_ASIO_SetRate, BASS_ASIO_Start