Author Topic: Bassmix output to 2 channels regardless of source  (Read 533 times)

smoodilo

  • Guest
I am using the bassmix matrix to send multiple input channels to multiple stereo outputs.
My problem is that stereo or 2-channel sources are correct, but mono sources are only sent to left or right channel.
I want to output to 2 channels regardless of the source.

What am I doing wrong?

smoodilo

  • Guest
Edit: Bassmix output to 2 channels regardless of source
« Reply #1 on: 29 May '19 - 15:10 »
...Or should I use a different approach and set the source decoding channel to output to 2 channels regardless of mono or stereo mp3?
Is this possible?

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: Bassmix output to 2 channels regardless of source
« Reply #2 on: 29 May '19 - 16:49 »
If you're using matrix mixing then the matrix determines what output channels the source gets played on (and at what level). To play a mono source at full level on both channels in a stereo mixer, you would do this:

Code: [Select]
float matrix[2][1] = { // 2 outputs x 1 input
{1}, // left out
{1} // right out
};
BASS_Mixer_ChannelSetMatrix(source, matrix);

Another option is to use a stereo BASS_SPEAKER flag in the BASS_Mixer_StreamAddChannel call (or BASS_Mixer_ChannelFlags), eg. BASS_SPEAKER_FRONT for front-left and front-right.

smoodilo

  • Guest
Re: Bassmix output to 2 channels regardless of source
« Reply #3 on: 29 May '19 - 17:05 »
The problem is that sometimes it is a mono channel (mp3) that is added to the matrix, and sometimes it is a stereo channel (mp3) that is added to the matrix.

So basically the matrix should check if an added channel (mp3) is mono, and only then send the same channel to left AND right.
If it is a stereo channel the matrix would direct left to left, and right to right.

Can the matrix check for this?

Smoodilo

  • Guest
Re: Bassmix output to 2 channels regardless of source
« Reply #4 on: 29 May '19 - 17:16 »
Edit: if I play a mono stream without matrix the sound is output to both left and right channel.
Somehow a decode stream added to the matrix only has sound on only one channel. If it would have sound on both left and righr there would be no problem with the matrix.

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: Bassmix output to 2 channels regardless of source
« Reply #5 on: 29 May '19 - 17:30 »
Each source has its own matrix, so you can set a different one for each, eg. depending on whether it's mono or stereo. Alternatively, if you're only using the matrix to set the output channels, you can use the BASS_SPEAKER flags for that instead (this way will also be a bit more efficient).

smoodilo

  • Guest
Re: Bassmix output to 2 channels regardless of source
« Reply #6 on: 29 May '19 - 18:17 »
Unfortunatelly that is not possible. I need to output some sources to  multiple outputs at the same time.
E.g.: input 1 to speakerpair 1 and 3, and input 2 to speakerpair 2 and 4.

This works perfectly with the matrix (except for some latency), but only if the stream is 2-channel.
Also I noticed that the program crashes if I use the speaker flags and the output is not there. With the matrix nothing crashes. Which is a big plus.

I'll see if I can come up with a solution to the problem myself, as I don't think I explain it right/ my problem is clear.

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: Bassmix output to 2 channels regardless of source
« Reply #7 on: 30 May '19 - 12:46 »
Please show what your matrix setting code currently looks like. It needs to consider how many channels the source has. BASS_ChannelGetInfo can be used to get that information (see "chans").

smoodilo

  • Guest
Re: Bassmix output to 2 channels regardless of source
« Reply #8 on: 31 May '19 - 11:29 »
Thanks Ian,

That's exactly what I did to solve it (First call channelgetinfo and then set the matrix according to the number of channels).

smoodilo

  • Guest
Re: Bassmix output to 2 channels regardless of source
« Reply #9 on: 17 Jun '19 - 10:37 »
I keep having problems with sending the right input to the right output. I think I don't understand how this works.

I have a matrix like this on a 7.1 soundcard:

matrix = {{L1, R1}, {L2, R2}, {L3, R3}, {L4, R4}, {L5, R5}, {L6, R6}, {L7, R7}, {L8, R8}}

Now, what I think this should be doing is...

-If I set L1 to 1, I should hear the source's left channel on speaker 1
-If I set R1 to 1, I should hear the source's right channel on speaker 1

-If I set L2 to 1, I should hear the source's left channel on speaker 2
-If I set R2 to 1, I should hear the source's right channel on speaker 2

-If I set L3 to 1, I should hear the source's left channel on speaker 3
-If I set R3 to 1, I should hear the source's right channel on speaker 3


...and so on.

Is this correct?






Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: Bassmix output to 2 channels regardless of source
« Reply #10 on: 17 Jun '19 - 12:23 »
Yes, that is correct, so long as the source is stereo.

smoodilo

  • Guest
Re: Bassmix output to 2 channels regardless of source
« Reply #11 on: 17 Jun '19 - 13:10 »
Yes, see, that is my problem. If I do this....

 If chaninfo.chans < 2 Then
                        'mono!!
                        L1 = 1
                        R1 = 1
                        L2 = 1
                        R2 = 1

                        L3 = 1
                        R3 = 1
                        L4 = 1
                        R4 = 1

                    Else
                        L1 = 0                                                              '
                        R1 = 1
                        L2 = 1
                        R2 = 0                                                           

                        L3 = 0
                        R3 = 1
                        L4 = 1
                        R4 = 0
End If

....This works for both channels of the first speaker pair. Even if it is a mono source. But on the second speaker pair I do not get any sound at all?



smoodilo

  • Guest
Re: Bassmix output to 2 channels regardless of source
« Reply #12 on: 17 Jun '19 - 13:39 »
To be clear: I do not get any sound on speaker 3 and 4 if the source is mono. If the source is stereo it works as expected.

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: Bassmix output to 2 channels regardless of source
« Reply #13 on: 17 Jun '19 - 16:03 »
Are you using the same matrix/array (posted above) for stereo and mono sources? The mono source matrix/array should look like this:

matrix = {{L1}, {L2}, {L3}, {L4}, {L5}, {L6}, {L7}, {L8}}

or:

matrix = {L1, L2, L3, L4, L5, L6, L7, L8}