我一直在尝试将32位立体声wav转换为16位单声道wav。我使用naudio捕获声音,并认为只使用两个或四个更重要的字节就可以解决问题。
以下是DataAvailable实现:
void _waveIn_DataAvailable(object sender, WaveInEventArgs e)
{
byte[] newArray = new byte[e.BytesRecorded / 2];
short two;
for (int i = 0, j = 0; i < e.BytesRecorded; i = i + 4, j = j + 2)
{
two = (short)BitConverter.ToInt16(e.Buffer, i + 2);
newArray[j] = (byte)(two & 0xFF);
newArray[j + 1] = (byte)((two >> 8) & 0xFF);
}
//do something with the new array:
}
任何帮助都将不胜感激!