我混合了四個緩衝區並應用平移。但是,當我觸發平移的變化時,我聽到一個剪輯。任何機構可以看到什麼是潛在的錯誤與下面的代碼: -DSP /手動混合和平移法
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處理。
@peter - 感謝您的回覆。我剛剛嘗試乘以0.25,並得到相同的剪輯。這隻發生在我動態改變平移時。 – Carl
好的 - 有沒有可能您的鍋值超出範圍,即< 0 or > 1? –
@peter - 永遠,我將它們編碼爲浮點數,1或0作爲測試。 – Carl