Changes the device that a stream, MOD music or sample is using.
Namespace: Un4seen.Bass
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax
[DllImportAttribute("bass")] public static bool BASS_ChannelSetDevice( int handle, int device )
Parameters
- handle
- Type: SystemInt32
The channel or sample handle... only HMUSIC, HSTREAM or HSAMPLE are supported. - device
- Type: SystemInt32
The device to use...0 = no sound, 1 = first real output device, BASS_NODEVICE (0x20000) = no device.
Return Value
Type: BooleanIf succesful, then is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Remarks
When changing a sample's device, all the sample's existing channels (HCHANNELs) are freed. It's not possible to change the device of an individual sample channel.
The BASS_NODEVICE (0x20000) option can be used to disassociate a decoding channel from a device, so that it does not get freed when BASS_Free is called.
ERROR CODE | Description |
---|---|
BASS_ERROR_HANDLE | handle is not a valid channel. |
BASS_ERROR_DEVICE | device is invalid. |
BASS_ERROR_INIT | The requested device has not been initialized. |
BASS_ERROR_ALREADY | The channel is already using the requested device. |
BASS_ERROR_NOTAVAIL | Only decoding channels are allowed to use the "no sound" device. |
BASS_ERROR_FORMAT | The sample format is not supported by the device/drivers. If the channel is more than stereo or the BASS_SAMPLE_FLOAT flag is used, it could be that they are not supported. |
BASS_ERROR_MEM | There is insufficient memory. |
BASS_ERROR_UNKNOWN | Some other mystery problem! |
Examples
// init device 1 and 2 Bass.BASS_Init(1, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle); // now device 1 is the current one Bass.BASS_Init(2, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle); // now device 2 is the current one ... // create the stream on device 1 Bass.BASS_SetDevice(1); // now device 1 is the current one int stream = Bass.BASS_StreamCreateFile("afile.mp3", 0, 0, BASSFlag.BASS_DEFAULT); Bass.BASS_ChannelPlay(stream, false); ... // move the channel to device 2 Bass.BASS_ChannelSetDevice(stream, 2);
See Also