Information Systems



Audio mixing attenuation function

So you want to mix audio samples algorithmically say in C++, but the max value often gets blown away. For instance:

.75 + .75 = 1.5; // when your max value is 1.0

The answer is an attenuation function.

Some people suggest this:

ms = s1 + s2 - (s1*s2);

Well, it's conceptually nice and it looks nice in terms of probabilities because it looks like merging probabilities for 2 independent events. However, it doesn't work. For instance:

1 = -1 + 1 - (-1*1);

Not a very nice result since the answer should be 0.

Tanh is a better function. It gives nice values that will never go above 1 or below -1.