BASS.NET API for the Un4seen BASS Audio LibraryBassAsioBASS_ASIO_Start Method (Int32)BASS.NET API for the Un4seen BASS Audio Library
Starts the current Asio device.

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

public static bool BASS_ASIO_Start(
	int buflen
)

Parameters

buflen
Type: SystemInt32
Buffer length in samples... 0 = use current length.

Return Value

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

Before starting the device, channels must be enabled using BASS_ASIO_ChannelEnable(Boolean, Int32, ASIOPROC, IntPtr). Once started, channels can't be enabled or disabled until the device is stopped, using BASS_ASIO_Stop.

ERROR CODEDescription
BASS_ERROR_INITBASS_ASIO_Init(Int32, BASSASIOInit) has not been successfully called.
BASS_ERROR_ALREADYThe device has already been started.
BASS_ERROR_NOCHANNo channels have been enabled.
BASS_ERROR_UNKNOWNSome other mystery problem!

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