Author Topic: bass.net: How to properly map multichannel bassmix to bassasio outputs?  (Read 93 times)

smooodilio

  • Guest
Trying to get this to work. I have set up a matrix mixer with bassmix. I have 4 stereo output channels (so effectively this is 8 asio channels). I cant get these mapped to the asio outputs. The code I have so far is:

Code: [Select]
    Private Sub InitializeAsio()
        ' Get soundcard information
        Dim SoundcardInfo As New BASS_INFO
        BASS_GetInfo(SoundcardInfo)

        ' Load BASS plugins
        Dim plugins() As String = {
        "bass_aac.dll", "basswma.dll", "bass_fx.dll",
        "bass_ac3.dll", "bassmix.dll", "bassasio.dll"
}
        For Each plugin As String In plugins
            BASS_PluginLoad(plugin)
        Next

        ' Configure network settings
        BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_TIMEOUT, 5000)
        BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_READTIMEOUT, 10000)
        BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_BUFFER, CInt(MyAppSettings.Item("Mixer.Buffer")))
        BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_PLAYLIST, 1)

        ' Initialize BASS
        If Not Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero) Then
            MessageBox.Show("BASS could not be initialized (no sound): " & Bass.BASS_ErrorGetCode().ToString())
            Return
        End If

        ' Initialize ASIO
        If Not BassAsio.BASS_ASIO_Init(0, BASSASIOInit.BASS_ASIO_THREAD) Then
            MessageBox.Show("ASIO could not be initialized. Error code: " & BassAsio.BASS_ASIO_ErrorGetCode().ToString())
            Return
        End If

        ' Set ASIO sample rate
        BassAsio.BASS_ASIO_SetRate(44100)

        ' Create matrix mixer
        STREAM_MATRIX = BassMix.BASS_Mixer_StreamCreate(44100, 4,
        BASSFlag.BASS_MIXER_NONSTOP Or
        BASSFlag.BASS_SAMPLE_FLOAT Or
        BASSFlag.BASS_STREAM_DECODE)

        ' Enable ASIO channel
        If Not BassAsio.BASS_ASIO_ChannelEnableBASS(False, 0, STREAM_MATRIX, True) Then
            MessageBox.Show("ASIO output channel could not be enabled. Error code: " & BassAsio.BASS_ASIO_ErrorGetCode().ToString())
            Return
        End If

        ' Start ASIO
        If Not BassAsio.BASS_ASIO_Start(0) Then
            MessageBox.Show("ASIO could not be started. Error code: " & BassAsio.BASS_ASIO_ErrorGetCode().ToString())
            Return
        End If
    End Sub


Basically what I understand from the docs is that if I plug the matrix mixer to the asio, it automatically uses as much channels as the matrix has. But the matrix has 4 stereo outputs, which should convert to 8 channels on the asio device if I am correct?

And there is one other thing I can't understand: To connect the matrix to asio it has to be set as decoding channel. But if I do this, functions like BASS_Mixer_ChannelIsActive and BASS_Mixer_ChannelPlay are not available/working anymore. So how do I control the input streams?

Ian @ un4seen

  • Administrator
  • Posts: 26171
You should set the BASS_Mixer_StreamCreate "chans" parameter to 8 (not 4) for 4x stereo outputs.

BASS_Mixer_ChannelIsActive/etc should still work when the mixer is a decoding channel (BASS_STREAM_DECODE). Are the function calls failing, and if so, what error code are they giving?

smooodilio

  • Guest
E.g. when calling BassMix.BASS_Mixer_ChannelIsActive I get an 'entrypoint not found' exception.

smooodilo

  • Guest
To enlighten:
If I call BassMix.BASS_Mixer_ChannelIsActive(STREAM1) without BassAsio it returns 0,1,2,3 or 4
If I call BassMix.BASS_Mixer_ChannelIsActive(STREAM1) with BassAsio it returns -1


Ian @ un4seen

  • Administrator
  • Posts: 26171
That looks like the "handle" parameter is invalid in the BassAsio case. Is the same handle working in BASS function calls, eg. BASS_ChannelFlags? If so, the handle is valid but it isn't currently plugged into a mixer, ie. it hasn't been used in a BASS_Mixer_StreamAddChannel(Ex) call?

smooodilo

  • Guest
You are right in that some channels are not plugged in yet. I use it to check if they are there. The docs say:

BASS_ACTIVE_STOPPED:   The source is not active, or handle is not a valid mixer source channel.

But it doesnt return Bass_Active_Stopped. Instead it returns -1.

Without hooking everything up to ASIO i get a clear bass_active_stopped.

Ian @ un4seen

  • Administrator
  • Posts: 26171
The BASS_Mixer_ChannelIsActive documentation doesn't include that "handle is not a valid mixer source channel" part:

   https://www.un4seen.com/doc/#bassmix/BASS_Mixer_ChannelIsActive.html

But I see it also doesn't mention -1 being returned upon failure, which is what BASS_Mixer_ChannelIsActive has always done. I'll add a note of that for the next BASSmix release.