BASS.NET API for the Un4seen BASS Audio LibraryBassMixBASS_Mixer_ChannelGetData Method (Int32, Int16, Int32)BASS.NET API for the Un4seen BASS Audio Library
Retrieves the immediate sample data of a mixer source channel. This overload uses a managed short[] to reference the buffer data as 16-bit values - each element will represent one channel in this case! SHOULD ONLY BE USED, if the stream was created WITHOUT BASS_SAMPLE_FLOAT or BASS_SAMPLE_8BITS!

Namespace: Un4seen.Bass.AddOn.Mix
Assembly: Bass.Net (in Bass.Net.dll) Version:

public static int BASS_Mixer_ChannelGetData(
	int handle,
	short[] buffer,
	int length


Type: SystemInt32
The handle of the mixer source channel (which was add via BASS_Mixer_StreamAddChannel(Int32, Int32, BASSFlag) or BASS_Mixer_StreamAddChannel(Int32, Int32, BASSFlag) or BASS_Mixer_StreamAddChannelEx(Int32, Int32, BASSFlag, Int64, Int64)) beforehand).
Type: SystemInt16
The array (short[]) to receive the data, e.g. when creating the channel stream with default setting, meaning 16-bit samples!
Type: SystemInt32
Number of bytes wanted, and/or the following flags (BASSData):
BASS_DATA_AVAILABLEQuery the amount of data the channel has buffered. This flag is primarily of use when recording, and can't be used with decoding channels as they do not have playback buffers. buffer can be when using this flag.

Return Value

Type: Int32
If an error occurs, -1 is returned, use BASS_ErrorGetCode to get the error code.

When requesting sample data, the number of bytes written to buffer will be returned (not necessarily the same as the number of bytes read).

When using the BASS_DATA_AVAILABLE flag, the number of bytes in the channel's buffer is returned.


This function is like the standard BASS_ChannelGetData(Int32, IntPtr, Int32), but it gets the data from the channel's buffer instead of decoding it from the channel, which means that the mixer doesn't miss out on any data. In order to do this, the source channel must have buffering enabled, via the BASS_MIXER_BUFFER flag.

If the mixer is being played by BASS, the returned data will be in sync with what is currently being heard from the mixer. If another output system is being used, the BASS_ATTRIB_MIXER_LATENCY option can be used to tell the mixer what the latency is so that it can be taken account of, otherwise the channel's most recent data will be returned. The BASS_CONFIG_MIXER_BUFFER config option determines how far back data will be available from, so it should be set high enough to cover any latency.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not plugged into a mixer.
BASS_ERROR_NOTAVAILThe channel does not have buffering (BASS_MIXER_BUFFER) enabled.

See Also