Sets the device to use for subsequent calls in the current thread.

BOOL BASS_SetDevice(
    DWORD device


deviceThe device to use... 0 = no sound, 1 = first real output device.

Return value

If successful, then TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_DEVICEdevice is invalid.
BASS_ERROR_INITThe device has not been initialized.


Simultaneously using multiple devices is supported in the BASS 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. The device setting is local to the current thread, so calling functions with different devices simultaneously in multiple threads is not a problem.

The functions that use the device selection are the following: BASS_Free, BASS_GetInfo, BASS_Start, BASS_Stop, BASS_Pause, BASS_SetVolume, BASS_GetVolume, BASS_Set3DFactors, BASS_Get3DFactors, BASS_Set3DPosition, BASS_Get3DPosition. It also determines which device is used by a new sample/stream/music: BASS_MusicLoad, BASS_SampleLoad, BASS_StreamCreateFile, etc.

When one of the above functions (or BASS_GetDevice) is called, BASS will check the current thread's device setting, and if no device is selected (or the selected device is not initialized), BASS will automatically select the lowest device that is initialized. This means that when using a single device, there is no need to use this function; BASS will automatically use the device that is initialized. Even if you free the device, and initialize another, BASS will automatically switch to the one that is initialized.


Create a stream of an MP3 file on device 2.
BASS_SetDevice(2); // select device 2
stream = BASS_StreamCreateFile(FALSE, "afile.mp3", 0, 0, 0); // create the stream

See also

BASS_ChannelGetDevice, BASS_ChannelSetDevice, BASS_GetDevice, BASS_Init