一种可以防止削波的混音方法

1860阅读 0评论2014-07-10 清谈先生
分类:Windows平台

公式如下:


一般方法的效果:


本方法的效果:


简单的实现方法:

点击(此处)折叠或打开

  1. nline SInt16 TPMixSamples(SInt16 a, SInt16 b) {
  2.     return
  3.             // If both samples are negative, mixed signal must have an amplitude between the lesser of A and B, and the minimum permissible negative amplitude
  4.             a < 0 && b < 0 ?
  5.                 ((int)a + (int)b) - (((int)a * (int)b)/INT16_MIN) :
  6.  
  7.             // If both samples are positive, mixed signal must have an amplitude between the greater of A and B, and the maximum permissible positive amplitude
  8.             ( a > 0 && b > 0 ?
  9.                 ((int)a + (int)b) - (((int)a * (int)b)/INT16_MAX)
  10.  
  11.             // If samples are on opposite sides of the 0-crossing, mixed signal should reflect that samples cancel each other out somewhat
  12.             :
  13.                 a + b);
  14. }

上一篇:Secret Rabbit Code (aka libsamplerate) 的API说明(1)
下一篇:Secret Rabbit Code (aka libsamplerate) 的Full API说明