Mixing is done by summing signals. Typically a mixing algorithm
would work something like this:
Signal a;
Signal b;
Signal c;
Gain g1;
Gain g2;
Pan p1;
Pan p2;
//where signal is a buffer of sound
//gain is a scalar for amplitude mixing
//and pan is a pan amount from left to right (i use from 0-1)
//now the mixing
c = pan(a,p1)*g1 + pan(b,p2)*g2;//where pan() is a panning function of some sort
//so if we have
Sample a(1,1);//left and right channel are equal to 1
Sample b(0.5,1);//same idea
Sample c;//storage for output
//now step by step
a = pan(a,0)*.75;//pan left and scale gain by 3/4;
//a = l:0.75 r:0
b = pan(b,1)*.75;//pan right and scale gain by 3/4;
//b = l:0 r:0.75
c = a +b;
//c = l:0.75 r:0.75
There are some more complexities involved sometimes but that is the basics as far as i understand. I tried to give my explanation in a pseudo code kind of manor I hope it is readable. Also my panning calculations are off but I think they make the point.
Good Luck