Could anybody give me any help mixing simultaneously multiple audio streams into one. I've tried several ways doing it, calculating average value of sample works ((stream1[sample] + stream2[sample]) / 2), but produces too quiet sound if some of the streams is silent or not too loud... If I do the mixing by using addition (stream1[sample] + stream[sample]) the resulting sample often exceeds the range and must be clipped... and if I mix something like 128 sounds sound is totally garbage...

Does anyone know any better methods? Using multiple DirectSound buffers and playing them simultaneusly works perfectly without any of these problems but I'd like to mix sounds myself without utililizing DirectSound.