我正在混合四个缓冲区并应用平移。但是,当我触发平移变化时,我会听到一个剪辑。任何人都可以看到以下代码可能有什么问题:-
for (int i = 0 ; i < numFrames; i++) {
//Convert buffer to float
float s1 = track1[0][i] / 32768.0f;
float s2 = track2[0][i] / 32768.0f;;
float s3 = track3[0][i] / 32768.0f;;
float s4 = track4[0][i] / 32768.0f;;
//Apply pan on track one
float s1R = s1 * sqrt( 1 - panA );
float s1L = s1 * sqrt( panA );
//Apply pan on track two
float s2R = s2 * sqrt( 1 - panB );
float s2L = s2 * sqrt( panB );
//Apply pan on track three
float s3R = s3 * sqrt( 1 - panC );
float s3L = s3 * sqrt( panC );
//Apply pan on track four
float s4R = s4 * sqrt( 1 - panD );
float s4L = s4 * sqrt( panD );
//Mix the right channel
float mixedR = s1R + s2R + s3R + s4R;
mixedR *= 0.6f;
if(mixedR > 1.0f) mixedR = 1.0f;
if(mixedR < -1.0f) mixedR = -1.0f;
//Mix the Left channel
float mixedL = s1L + s2L + s3L + s4L;
mixedL *= 0.6f;
if(mixedL > 1.0f) mixedL = 1.0f;
if(mixedL < -1.0f) mixedL = -1.0f;
//Apply the Left channel
audioIn[0][i] = (short) (mixedL * 32768.0f);
//Apply the right channel
audioIn[1][i] = (short) (mixedR * 32768.0f);
}
平移算法可以改进,我从这里提出:-
http://www.kvraudio.com/forum/viewtopic.php?t=181222&postdays=0&postorder=asc&start=0
NumFrames 为 512;混合音频后,我将使用 Dirac 应用时间拉伸算法。
剪裁在没有经过 Dirac 处理的情况下发生。