BASS.NET API for the Un4seen BASS Audio Library

BassAsioHandler Constructor (Int32, Int32, Int32, BASSASIOFormat)

BASS.NET API for the Un4seen BASS Audio Library
Creates an instance of the ASIO handler for output - initializing and enabling the given ASIO device and channel according to the Bass stream.

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

public BassAsioHandler(
	int asioDevice,
	int asioChannel,
	int outputChannel,
	BASSASIOFormat format = BASSASIOFormat.BASS_ASIO_FORMAT_UNKNOWN
)

Parameters

asioDevice
Type: SystemInt32
The ASIO device to use (0=first).
asioChannel
Type: SystemInt32
The ASIO output channel number (0=first).
outputChannel
Type: SystemInt32
The BASS channel handle which should be used with ASIO output (must be a decoding or recording channel and must be either 16-bit or 32-bit).
format (Optional)
Type: Un4seen.BassAsioBASSASIOFormat
The ASIO sample format to use for the channel(s) - see BASSASIOFormat for details. Use -1 (UNKNOWN) to apply the format automatically.
Exceptions

ExceptionCondition
ArgumentExceptionInvalid channel: must be a valid BASS channel (either decoding or recording).
Remarks

Use this constructor for automatic Asio output using either a decoding or recording outputChannel.

The following will be done internally:

1. The ASIO device will be initialized (if already done, the ASIO device will just be set).

2. The samplerate, format and number of channels will be determined from the given outputChannel.

3. The ASIO device will be set to the determined samplerate. If this fails, the current ASIO samplerate will not be changed. In this case it might happen (if ASIO device samplerate and stream samplerate are different) that the ASIO output needs to be resampled.

4. Output: use the AsioOutputCallback(Boolean, Int32, IntPtr, Int32, IntPtr) as the internal ASIOPROC.

4. Enable and join the given asioChannel with the following channels according to the total number of chans of the outputChannel.

5. Set the asioChannel format and samplerate according to the given samplerate and format of the outputChannel.

Note: If the given asioChannel has already been enabled, it will be reused and not enabled and joined again! This means, that the channel number of the already joined channel will not be changed as well and might not match to the channel number of the given outputChannel.

Examples

Automatic use of the BassAsioHandler (Asio output from a Bass stream):
private BassAsioHandler _asio;
...
// not playing anything via BASS, so don't need an update thread
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0);
// setup BASS - "no sound" device but 48000 (default for ASIO)
Bass.BASS_Init(0, 48000, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
BassAsio.BASS_ASIO_Init(0, BASSASIOInit.BASS_ASIO_THREAD);
...
int stream = Bass.BASS_StreamCreateFile(fileName, 0, 0, 
                  BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
if (stream != 0)
{
  // assign ASIO output to the first device and channel
  // and assume the ASIO format, samplerate and number of channels from the BASS stream
  _asio = new BassAsioHandler(0, 0, stream);
  // start ASIO
  _asio.Start(0);
}
See Also

Reference