
一般方法的效果:

本方法的效果:

简单的实现方法:
点击(此处)折叠或打开
-
nline SInt16 TPMixSamples(SInt16 a, SInt16 b) {
-
return
-
// If both samples are negative, mixed signal must have an amplitude between the lesser of A and B, and the minimum permissible negative amplitude
-
a < 0 && b < 0 ?
-
((int)a + (int)b) - (((int)a * (int)b)/INT16_MIN) :
-
-
// If both samples are positive, mixed signal must have an amplitude between the greater of A and B, and the maximum permissible positive amplitude
-
( a > 0 && b > 0 ?
-
((int)a + (int)b) - (((int)a * (int)b)/INT16_MAX)
-
-
// If samples are on opposite sides of the 0-crossing, mixed signal should reflect that samples cancel each other out somewhat
-
:
-
a + b);
- }