BASS.NET API for the Un4seen BASS Audio LibraryBassAsioHandlerSetFullDuplex Method (Int32, Int32)BASS.NET API for the Un4seen BASS Audio Library
Sets the full-duplex option for ASIO input using the given ASIO output device and channel.

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

public bool SetFullDuplex(
	int asioDevice,
	int asioChannel
)

Parameters

asioDevice
Type: SystemInt32
The ASIO output device which should be used for full-duplex monitoring.
asioChannel
Type: SystemInt32
The ASIO output channel which should be used for full-duplex monitoring.

Return Value

Type: Boolean
On success is returned, else will be returned (use BASS_ASIO_ErrorGetCode to retrieve the error code).
Remarks

The full-duplex options is only available on input channels. However even a full-duplex output channel on a different ASIO device might even be used.

If you want to mirror an ASIO input channel to an output channel on the same device, you might might also use the SetMirror(Int32) method instead, which is more efficient in such case.

The following will be done internally:

1. The ASIO input Channel will be used (and enabled and joined, only if not enabled yet).

2. A custom dummy decoding stream (see OutputChannel) will be created with the AsioToAsioFullDuplexCallback(Boolean, Int32, IntPtr, Int32, IntPtr) as the internal ASIOPROC.

3. The samplerate, format and number of channels will not be changed for ASIO input, since this will be used as already specified in the constructor.

4. The ASIO output asioDevice will only be stopped, if already started and the asioChannel has not yet been enabled - it will automatically be started again if needed.

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

6. The ASIO output asioChannel will be enabled and joined (only if not already enabled) as well as the format and samplerate will be set. All according to the given number of channels, samplerate and format of the ASIO input Channel.

This method can not be used with ASIO output (see IsInput). It will immediately return with no effect.

To disable and remove the full-duplex option call RemoveFullDuplex(Boolean).

The full-duplex ASIO output is provided by an internal custom dummy decoding stream OutputChannel. You might use this stream to set up DSPs or FX on it so that these are applied on the ASIO output.

You might bypass any full-duplex output procesing by setting the BypassFullDuplex property to .

Examples

Automatic use of the BassAsioHandler (Asio recording input, full-duplex Asio output):
VB
Private _asio As BassAsioHandler
Private _plm As DSP_PeakLevelMeter
...
' assign ASIO input to the first device and channel (stereo, 32-bit float, 48kHz)
_asio = New BassAsioHandler(True, 0, 0, 2, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT, 48000)
' set the full-duplex option to the first ASIO output device and channel
' the ASIO output format will always be the same as the input for full-duplex
_asio.SetFullDuplex(0, 0)

' set up a ready-made DSP (here the PeakLevelMeter) on the full-duplex channel
_plm = New DSP_PeakLevelMeter(_asio.OutputChannel, 0)
_plm.UpdateTime = 0.1F ' 100ms
_plm.CalcRMS = True
AddHandler _plm.Notification, AddressOf OnPlmNotification

' start ASIO
BassAsio.BASS_ASIO_Start(0)
...
Private Sub OnPlmNotification(sender As Object, e As EventArgs)
  If _plm Is Nothing Then
    Return
  End If
  ' sender will be the DSP_PeakLevelMeter instance
  ' you could also access it via: 
  ' Dim p As DSP_PeakLevelMeter = CType(sender, DSP_PeakLevelMeter)
  Me.progressBarPeak1Left.Value = _plm.LevelL
  Me.progressBarPeak1Right.Value = _plm.LevelR
  Me.labelLevel1.Text = [String].Format("RMS: {0:#00.0} dB   AVG: {1:#00.0} dB   Peak: {2:#00.0} dB", 
     _plm.RMS_dBV, _plm.AVG_dBV, Math.Max(_plm.PeakHoldLevelL_dBV, _plm.PeakHoldLevelR_dBV))
End Sub
private BassAsioHandler _asio;
private DSP_PeakLevelMeter _plm;
...
// assign ASIO input to the first device and channel (stereo, 32-bit float, 48kHz)
_asio = new BassAsioHandler(true, 0, 0, 2, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT, 48000);
// set the full-duplex option to the first ASIO output device and channel
// the ASIO output format will always be the same as the input for full-duplex
_asio.SetFullDuplex(0, 0);

// set up a ready-made DSP (here the PeakLevelMeter) on the full-duplex channel
_plm = new DSP_PeakLevelMeter(_asio.OutputChannel, 0);
_plm.UpdateTime = 0.1f; // 100ms
_plm.CalcRMS = true;
_plm.Notification += new EventHandler(OnPlmNotification);

// start ASIO
BassAsio.BASS_ASIO_Start(0);
...
private void OnPlmNotification(object sender, EventArgs e)
{
  if (_plm == null)
    return;
  // sender will be the DSP_PeakLevelMeter instance
  // you could also access it via: DSP_PeakLevelMeter p = (DSP_PeakLevelMeter)sender;
  this.progressBarPeak1Left.Value = _plm.LevelL;
  this.progressBarPeak1Right.Value = _plm.LevelR;
  this.labelLevel1.Text = String.Format( "RMS: {0:#00.0} dB   AVG: {1:#00.0} dB   Peak: {2:#00.0} dB", 
       _plm.RMS_dBV, _plm.AVG_dBV, Math.Max(_plm.PeakHoldLevelL_dBV, _plm.PeakHoldLevelR_dBV) );
}
See Also

Reference