BASS.NET API for the Un4seen BASS Audio LibraryBassAsioBASS_ASIO_ChannelEnable Method BASS.NET API for the Un4seen BASS Audio Library
Enable/disable processing of an Asio channel.

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

[DllImportAttribute("bassasio.dll", CharSet = CharSet.Auto)]
public static bool BASS_ASIO_ChannelEnable(
	bool input,
	int channel,
	ASIOPROC proc,
	IntPtr user
)

Parameters

input
Type: SystemBoolean
Dealing with an input channel? = an output channel.
channel
Type: SystemInt32
The input/output channel number... 0 = first.
proc
Type: Un4seen.BassAsioASIOPROC
The user defined function to process the channel... = disable the channel.
user
Type: SystemIntPtr
User instance data to pass to the callback function.

Return Value

Type: Boolean
If succesful, then is returned, else is returned. Use BASS_ASIO_ErrorGetCode to get the error code.
Remarks

All ASIO channels are mono. Stereo (and above) channels can be formed by joining multiple channels together using BASS_ASIO_ChannelJoin(Boolean, Int32, Int32).

Use BASS_ASIO_Start(Int32) to begin processing the enabled channels.

You might also use this function on an already enabled ASIO channel if you just want to change the ASIOPROC which should be used. However changing the callback procedure to would disable the channel - which is only possible, if the ASIO device is stopped.

ERROR CODEDescription
BASS_ERROR_INITBASS_ASIO_Init(Int32, BASSASIOInit) has not been successfully called.
BASS_ERROR_STARTThe device has been started - it needs to be stopped before (dis)enabling channels.
BASS_ERROR_ILLPARAMThe input and channel combination is invalid.

Examples

VB
Imports Un4seen.Bass
Imports Un4seen.BassAsio
...
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
BassAsio.BASS_ASIO_Init(0, BASSASIOInit.BASS_ASIO_THREAD)
...
Dim stream As Integer = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT)
If stream <> 0 Then
  ' now setup ASIO
  _myAsioProc = New ASIOPROC(AddressOf AsioCallback)
  ' enable 1st output channel...(0=first)
  BassAsio.BASS_ASIO_ChannelEnable(False, 0, _myAsioProc, New IntPtr(stream))
  ' and join the next channels to it
  BassAsio.BASS_ASIO_ChannelJoin(False, 1, 0)
  ' and start playing it...start output using default buffer/latency
  BassAsio.BASS_ASIO_Start(0)
End If
...
Private _myAsioProc As ASIOPROC ' make it global, so that it can not be removed by the Garbage Collector
Private Function AsioCallback(input As Boolean, channel As Integer, buffer As IntPtr, length As Integer, user As IntPtr) As Integer
  ' Note: 'user' contains the underlying stream channel (see above)
  ' We can simply use the bass method to get some data from a decoding channel 
  ' and store it to the asio buffer in the same moment...
  Return Bass.BASS_ChannelGetData(user.ToInt32(), buffer, length)
End Function
using Un4seen.Bass;
using Un4seen.BassAsio;
...
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
BassAsio.BASS_ASIO_Init(0, BASSASIOInit.BASS_ASIO_THREAD);
...
int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
if (stream != 0)
{
    // now setup ASIO
    _myAsioProc = new ASIOPROC(AsioCallback);
    // enable 1st output channel...(0=first)
    BassAsio.BASS_ASIO_ChannelEnable(false, 0, _myAsioProc, new IntPtr(stream));
    // and join the next channels to it
    BassAsio.BASS_ASIO_ChannelJoin(false, 1, 0);
    // and start playing it...start output using default buffer/latency
    BassAsio.BASS_ASIO_Start(0);
}
...
private ASIOPROC _myAsioProc; // make it global, so that it can not be removed by the Garbage Collector
private int AsioCallback(bool input, int channel, IntPtr buffer, int length, IntPtr user)
{
    // Note: 'user' contains the underlying stream channel (see above)
    // We can simply use the bass method to get some data from a decoding channel 
    // and store it to the asio buffer in the same moment...
    return Bass.BASS_ChannelGetData(user.ToInt32(), buffer, length);
}
See Also

Reference