如何使用 naudio 将立体声 pcm 样本转换为单声道样本?
或将立体声 mp3 文件转换为单声道原始样本!
我之前试试这个:
for (int u = 0; u < output.Length; u+=4)
{
byte[] Lbuffer = new byte[2];
byte[] Rbuffer = new byte[2];
Lbuffer[0] = output[u + 0];
Lbuffer[1] = output[u + 1];
Rbuffer[0] = output[u + 2];
Rbuffer[1] = output[u + 3];
Int16 leftSample = BitConverter.ToInt16(Lbuffer, 0);
Int16 rightSample = BitConverter.ToInt16(Rbuffer, 0);
Int16 mixedMono = (Int16)(0.5f * (float)leftSample + (float)rightSample);
Byte[] mixedMonoBytes = BitConverter.GetBytes(mixedMono);
mono[counter] = mixedMonoBytes[0];
mono[counter+1] = mixedMonoBytes[1];
//mono[counter] = Convert.ToByte((Convert.ToInt16(buffer[0]) + Convert.ToInt16(buffer[2]))/2);
//mono[counter+1] = Convert.ToByte((Convert.ToInt16(buffer[0]) + Convert.ToInt16(buffer[2]))/2);
counter += 2;
}
但它目前不起作用!结果有噪音!输出是一个包含原始样本的数组!