BASS.NET API for the Un4seen BASS Audio LibraryBassAsioHandlerAsioOutputCallback Method BASS.NET API for the Un4seen BASS Audio Library
Provides a ready made ASIOPROC callback procedure which might be used for ASIO output.

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

public virtual int AsioOutputCallback(
	bool input,
	int channel,
	IntPtr buffer,
	int length,
	IntPtr user
)

Parameters

input
Type: SystemBoolean
Dealing with an input channel? Must be , since we are dealing with Asio output.
channel
Type: SystemInt32
The output channel number... 0 = first.
buffer
Type: SystemIntPtr
The pointer to the buffer in which to put the data to output.
length
Type: SystemInt32
The number of BYTES to process.
user
Type: SystemIntPtr
Not used.

Return Value

Type: Int32
The number of bytes written.
Remarks

Notes:

In order to use this default output ASIO callback (playback), you need to make sure that you use this callback only with ASIO output (IsInput must be ).

Furthermore the following should be considered: If the underlying stream channel OutputChannel is at the end (all data was decoded), this callback does NOT automatically pause ASIO via BASS_ASIO_ChannelPause(Boolean, Int32) or Pause(Boolean). So you need to do that by yourself (if you whish to save some performance), e.g. setup a BASS_SYNC_END on the OutputChannel. If the underlying OutputChannel returns less data, than requested the ASIO output buffer will be filled with 0's (silence).

Internally BASS_ChannelGetData(Int32, IntPtr, Int32) will be called on the underlying OutputChannel to request sample data, before the sample data is send to the ASIO output.

If you intend to overload this callback in a derive implementation make sure to call the base method to not loose any functionatily.

Examples

Implementing your own callback in a derived implementation:
VB
Public Class MyAsioHandler 
  Inherits BassAsioHandler

  Public Overrides Function AsioOutputCallback(input As Boolean, channel As Integer, buffer As IntPtr, length As Integer, user As IntPtr) As Integer
    ' buffer is already filled
    ' do your own stuff here...
    Dim len As Integer = MyBase.AsioOutputCallback(input, channel, buffer, length, user)
    If len > 0 Then
      ' buffer is already filled
      ' do your own stuff here...
    End If
    Return len
  End Function

End Class
public class MyAsioHandler : BassAsioHandler
{

  public override int AsioOutputCallback(bool input, int channel, IntPtr buffer, int length, IntPtr user)
  {
    // buffer is not filled
    // do your own stuff here...
    int len = base.AsioOutputCallback(input, channel, buffer, length, user);
    if (len > 0)
    {
      // buffer is already filled
      // do your own stuff here...
    }
    return len;
  }

}
See Also

Reference