### Author Topic: Matrix mixing  (Read 1180 times)

#### 3delite

• Posts: 926
##### Matrix mixing
« on: 12 Dec '11 - 10:18 »
Hi!

I am implementing an option in my application to specify an output channel configuration. I am playing a never ending stream as the main mixer into which I plug in in streams that I want to play.

I want to upmix/downmix the plugged in stream to play at all output channels.

There is a BASS_MIXER_DOWNMIX flag. It is not written in the docs what downmix matrix does it use?

Also there is no "upmix" flag. Why is that?
But no problem I'll implement my own upmixing matrix if there is no one.

And one more question. If I use a matrix like (stereo in - stereo out):

1,1
1,1

then will this result clipping (eg. if sample value is 1 and 1 this will result 2 that is outside the float range of -1 to +1), right?

That's all.

Best regards
3delite

#### Ian @ un4seen

• Posts: 21186
##### Re: Matrix mixing
« Reply #1 on: 12 Dec '11 - 14:20 »
There is a BASS_MIXER_DOWNMIX flag. It is not written in the docs what downmix matrix does it use?

It will depend on the number of inputs and outputs. You can use BASS_Mixer_ChannelGetMatrix to find out

And one more question. If I use a matrix like (stereo in - stereo out):

1,1
1,1

then will this result clipping (eg. if sample value is 1 and 1 this will result 2 that is outside the float range of -1 to +1), right?

Yes, that is quite likely to result in clipping; you would probably want to change the "1" to "0.5". Note that matrix will actually result in mono sound, as the left and right outputs both contain an equal mix of the left and right inputs. A "stereo in - stereo out" matrix would look like this...

Code: [Select]
`float matrix[2][2]={    {1, 0}, // left out = left in    {0, 1} // right out = right in};`

#### 3delite

• Posts: 926
##### Re: Matrix mixing
« Reply #2 on: 15 Dec '11 - 14:42 »
It will depend on the number of inputs and outputs. You can use BASS_Mixer_ChannelGetMatrix to find out

I belive you that it will work, for now.
When I have time for it, I'll check the matrixes.

And one more question. If I use a matrix like (stereo in - stereo out):

1,1
1,1

then will this result clipping (eg. if sample value is 1 and 1 this will result 2 that is outside the float range of -1 to +1), right?

Yes, that is quite likely to result in clipping; you would probably want to change the "1" to "0.5". Note that matrix will actually result in mono sound, as the left and right outputs both contain an equal mix of the left and right inputs. A "stereo in - stereo out" matrix would look like this...

Code: [Select]
`float matrix[2][2]={    {1, 0}, // left out = left in    {0, 1} // right out = right in};`

Ok. I think I understand matrix mixing. For a short summary: horizontally the sum of the values should be below or equal 1.

Thanx for the info!

Best regards
3delite