Author Topic: Bassmix matrix please explain  (Read 181 times)

Smoodilo

  • Guest
Bassmix matrix please explain
« on: 5 Nov '18 - 19:57 »
I am trying to get the concept of bassmix matrix.

In my program I have 2 separate streams (Deck A and Deck B). Currently both streams output to the same speaker pair, so they act as one output stream.
What I want is the ability to send both streams to speakerpair 1 OR speakerpair 2, but also switch to send them to speakerpair 1 AND speakerpair 2.

What I did is
-First create and start a matrix channel

Public Sub CreateMatrixChannel()
        Dim ci As New BASS_CHANNELINFO
        Dim di As New BASS_INFO

        BASS_StreamFree(STREAM_MATRIX)
        BASS_GetInfo(di) ' get device info for speaker count

        STREAM_MATRIX = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamCreate(44100, di.speakers, BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_MIXER_NONSTOP) ' create mixer with source    sample rate and device speaker count
        BASS_ChannelPlay(STREAM_MATRIX, False)
    End Sub



After that I added the streams like this:
Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(STREAM_MATRIX, STREAM_MAIN1,  BASSFlag.BASS_MIXER_MATRIX)
Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(STREAM_MATRIX, STREAM_MAIN2,  BASSFlag.BASS_MIXER_MATRIX)


My problem is that in all examples the streams are started by starting the Matrix channel like this:
Bass.BASS_ChannelPlay(STREAM_MATRIX, False)


But I need to start, stop and load both streams separataly. So I would want to start like this:
Bass.BASS_ChannelPlay(STREAM_MAIN1, False)
Bass.BASS_ChannelPlay(STREAM_MAIN2, False)


Questions:
-Is this the right way to do this?
-Why is my output at the wrong speed?



Maybe I just don't understand the concept? Who is willing to help?









Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: Bassmix matrix please explain
« Reply #1 on: 6 Nov '18 - 17:05 »
To start a source, you just need to add it to the mixer via BASS_Mixer_StreamAddChannel/Ex. To stop a source, you remove it via BASS_Mixer_ChannelRemove. To pause/resume a source, you can set/unset the BASS_MIXER_PAUSE flag on it via BASS_Mixer_ChannelFlags.

Regarding the "wrong speed", are you referring to the mixer itself or the sources plugged in it? In either case, have you changed the BASS_ATTRIB_FREQ settings, or perhaps used the BASS_FX add-on's tempo processing?

smoodilo

  • Guest
Re: Bassmix matrix please explain
« Reply #2 on: 6 Nov '18 - 17:41 »
But by pausing and resuming the source by using Bass_mixer_pause, I pause and resume the mixer (so ALL music that is currently being played), and not the individual streams. I need to change (pause,resume, stop...) SOURCE A while SOURCE B is playing, and vice versa.




Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: Bassmix matrix please explain
« Reply #3 on: 6 Nov '18 - 17:58 »
The BASS_MIXER_PAUSE flag is set on individual sources (via BASS_Mixer_StreamAddChannel/Ex or BASS_Mixer_ChannelFlags), not the mixer itself. Other sources are unaffected.

Smoodilo

  • Guest
Re: Bassmix matrix please explain
« Reply #4 on: 7 Nov '18 - 16:43 »
Ok,

So far  have it working.

Now my problem is that it seems like EndSync on the decoding channels is no longer fired when VolumeSliding.


I tried with:
Bass.BASS_ChannelSetSync(STREAM_MAIN1, BASSSync.BASS_SYNC_END, 0, mySync1, IntPtr.Zero)

and with

Bassmix.BASS_MIXER_ChannelSetSync(STREAM_MAIN1, BASSSync.BASS_SYNC_END, 0, mySync1, IntPtr.Zero)


The channels start sliding, but the endsync is never fired.
I need to remove the channels after sliding the volume to 0 is completed.

Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: Bassmix matrix please explain
« Reply #5 on: 7 Nov '18 - 17:54 »
I guess you are doing something like this?

Code: [Select]
BASS_ChannelSlideAttribute(STREAM_MAIN1, BASS_ATTRIB_VOL, -1, 1000);

If so, a BASS_SYNC_END sync won't triggered by that (they're only triggered at the end of the file), but you could use a BASS_SYNC_SLIDE sync instead.

Smoodilo

  • Guest
Re: Bassmix matrix please explain
« Reply #6 on: 8 Nov '18 - 14:24 »
I guess you are doing something like this?

Code: [Select]
BASS_ChannelSlideAttribute(STREAM_MAIN1, BASS_ATTRIB_VOL, -1, 1000);

If so, a BASS_SYNC_END sync won't triggered by that (they're only triggered at the end of the file), but you could use a BASS_SYNC_SLIDE sync instead.


Thanks Ian, that worked…


One more question: I can set the matrix while a stream is playing (without restarting), which is very cool. But this does not seem to work with StreamCreateURL streams, only on local streams. Is this correct? Or is there still something wrong in my code?









Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: Bassmix matrix please explain
« Reply #7 on: 8 Nov '18 - 17:39 »
Matrix mixing works the same on all sources, so there should be no difference between using it on local and internet streams. Does the BASS_Mixer_ChannelSetMatrix return value indicate success or failure, and if the latter, what is the error code?