答案比我想象的要简单。我只需要将ALaw转换为PCM,然后
添加两个波流,我使用G711代码项目文章中的ALawDecoder完成了这一操作。
r1 = new WaveFileReader(...);
r2 = new WaveFileReader(...);
r1.Read(arr1, 0, arr1.Length);
r2.Read(arr2, 0, arr2.Length);
short[] firstPCM16 = ALawDecoder.ALawDecode(arr1);
short[] secondPCM16 = ALawDecoder.ALawDecode(arr2);
byte[] result1 = new byte[firstPCM16.Length * sizeof(short)];
byte[] result1 = new byte[secondPCM16.Length * sizeof(short)];
Buffer.BlockCopy(firstPCM16, 0, result1, 0, result1.Length);
Buffer.BlockCopy(secondPCM16, 0, result2, 0, result2.Length);
for (...)
{
mixed[i] = (byte)(result1[i] + result2[i]);//No need to dividing by 2 because r1 and r2 are 8 bit ALaw and return value of ALawDecoder is 16 bit pcm
}