balancing two or more signals- math problem

12root2's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi. I'm trying to make a utility for stereo Combined Panning. I managed to do that but I have some problems with the math. Unlike regular panning, when sending the signal to the left the right channel doesn't vanish, It is sent to the left channel, and as a result, the channel would clip unless I process the sum of the channels in some way (halving its amplitude, for example).
But I can't find the right math. for example, when not processed (left is sent to the left end and the right to the right) the gain is dropped compered to the source.
I'm looking for a way to sum signals with different amplitudes without the gain loss.
here's what I have so far:

Roman Thilenius's icon

/2 for 2 channels, /3 for 3.

there is no alternative to it, either the sources must be lowered, or the summ will be over 0db/A.

Roman Thilenius's icon

where is the edit button when you need it.