On Monday 26 January 2004 22:54, Guido Henkel wrote:
> Your samples are clipping, that's what you're hearing.
>
> What you have to do is to add the two of them and then create the average.
>
> destSample = ( sample1 + sample2 ) / 2;
uuuwww... no, please dont, this is a common misconception. while this will
prevent the clipping, it is still not what you want.
what you need to do is
a) sum up the amplitudes of all channels you want to mix, ie in your
case sum=smp1+smp2
b) clamp the resulting value against the high and the low limit like this:
if (sum>highlimit) sum=highlimit;
else if(sum<lowlimit) sum=lowlimit;
gpz