BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_SampleGetChannels Method (Int32, Int32)BASS.NET API for the Un4seen BASS Audio Library
Retrieves all a sample's existing channels.

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

public static int BASS_SampleGetChannels(
	int handle,
	int[] channels


Type: SystemInt32
Handle of the sample.
Type: SystemInt32
The array (int[])to put the sample's channel handles in. The array should be the same size as the sample's max setting when the sample was created, which can be retrieved using BASS_SampleGetInfo(Int32, BASS_SAMPLE). can be used to just check how many channels exist.

Return Value

Type: Int32
If successful, the number of existing channels is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code.

For ease of use you might also use the second overload, which directly returns an integer array to get the channels directly.

If you need to determine whether a particular sample channel still exists, it is simplest to just try it in a function call, eg. BASS_ChannelGetAttribute(Int32, BASSAttribute, Single).

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not a valid sample handle.


Set the sample rate of all a sample's channels to 10000Hz:
' get sample info for "max" value
Dim info As BASS_SAMPLE = Bass.BASS_SampleGetInfo(handle)
' allocate channels array
Dim chans(info.max) As Integer
' get the channels
Dim count As Integer = Bass.BASS_SampleGetChannels(handle, hGC.AddrOfPinnedObject())
' go through them all and...
Dim a As Integer
For a = 0 To count - 1
  ' set the sample rate to 10000
  Bass.BASS_ChannelSetAttribute(chans(a), BASSAttribute.BASS_ATTRIB_FREQ, 10000F)
Next a
// get sample info for "max" value
BASS_SAMPLE info = Bass.BASS_SampleGetInfo(handle);
// allocate channels array
int[] chans = new int[info.max];
// get the channels
int count = Bass.BASS_SampleGetChannels(handle, chans);
// go through them all and...
for (int a=0; a<count; a++)
  // set the sample rate to 10000
  Bass.BASS_ChannelSetAttribute(chans[a], BASSAttribute.BASS_ATTRIB_FREQ, 10000f);
See Also