BASS.NET API for the Un4seen BASS Audio Library

BassAsioBASS_ASIO_ChannelEnableMirror Method

BASS.NET API for the Un4seen BASS Audio Library
Enables an output channel, and makes it mirror another channel.

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

[DllImportAttribute("bassasio")]
public static bool BASS_ASIO_ChannelEnableMirror(
	int channel,
	bool input2,
	int channel2
)

Parameters

channel
Type: SystemInt32
The output channel number... 0 = first.
input2
Type: SystemBoolean
Mirroring an input channel? = an output channel.
channel2
Type: SystemInt32
The channel to mirror.

Return Value

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

This function allows an input or output channel to be duplicated in other output channel. This can be achieved using normal ASIOPROC processing, but it's more efficient to let BASSASIO simply copy the data from one channel to another.

Mirror channels can't be joined together to form multi-channel mirrors. Instead, to mirror multiple channels, an individual mirror should be setup for each of them.

After BASS_ASIO_Start(Int32) has been called to begin processing, it's not possible to setup new mirror channels, but it is still possible to change the channel that a mirror is mirroring.

When mirroring an output channel that hasn't been enabled, the mirror channel will just produce silence. When mirroring an input channel that hasn't already been enabled, the channel is automatically enabled for processing when BASS_ASIO_Start(Int32) is called, so that it can be mirrored. If the mirror is switched to a disabled input channel once processing has begun, then it will produce silence.

A mirror channel can be made to have a different volume level to the channel that it's mirroring, using BASS_ASIO_ChannelSetVolume(Boolean, Int32, Single). The volume setting is cumulative. For example, if the mirror channel has a volume setting of 0.5 and the mirrored channel has a volume setting of 0.4, the effective volume of the mirror channel will be 0.2 (0.5 x 0.4).

BASS_ASIO_ChannelEnable(Boolean, Int32, ASIOPROC, IntPtr) can be used to disable a mirror channel.

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 enabling channels.
BASS_ERROR_ILLPARAMAt least one of the channels is invalid.
BASS_ERROR_FORMATIt is not possible to mirror channels that do not have the same sample format.

Examples

Enable output channel 0, and mirror it to channel 1 for stereo output:
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));
    // mirror it to channel 1
    BassAsio.BASS_ASIO_ChannelEnableMirror(1, false, 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 GC
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