BASS.NET API for the Un4seen BASS Audio Library

BassAsioBASS_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.17.5
Syntax

[DllImportAttribute("bassasio")]
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

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);
    // since we joined the channels, the next commands will apply to all channles joined
    // so setting the values to the first channels changes them all automatically
    // set the source format (float, as the decoding channel is)
    BassAsio.BASS_ASIO_ChannelSetFormat(false, 0, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT);
    // 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