Wavein_DataAvailable 给出的数据是预期的两倍

Wavein_DataAvailable gives twice as much data as expected

我正在使用 Naudio 从麦克风读取数据,但考虑到我使用的波形,获得的数据是我预期的两倍。

... bunch of constructor code ....

    waveFormat = new WaveFormat(8000, 8, 1);

    bwp_MicToModem = new BufferedWaveProvider(waveFormat);
    bwp_MicToModem.DiscardOnBufferOverflow = true;
    bwp_MicToModem.BufferLength = 1000;
    bwp_MicToModem.ReadFully = false;

    wavein = new WaveIn();
    wavein.DeviceNumber = 0;
    wavein.BufferMilliseconds = 50;
    wavein.DataAvailable += Wavein_DataAvailable;
 }

private void Wavein_DataAvailable(object sender, WaveInEventArgs e)
{
    bwp_MicToModem.AddSamples(e.Buffer, 0, e.BytesRecorded);
    threadSafeAppendText("data event, bytes " + e.BytesRecorded, true);
}

这有点管用,但每 50 毫秒产生 800 字节的数据。

来自我的日志文件:

2019-03-27 14:41:26.765 : data event, bytes 800
2019-03-27 14:41:26.775 : readRate (ms) 0 numBytes 63
2019-03-27 14:41:26.775 : writeRate, modem.write (ms) 47 bytesFrMic 400
2019-03-27 14:41:26.785 : readRate (ms) 0 numBytes 96
2019-03-27 14:41:26.795 : readRate (ms) 3 numBytes 1
2019-03-27 14:41:26.805 : readRate (ms) 0 numBytes 63
2019-03-27 14:41:26.815 : readRate (ms) 0 numBytes 64
2019-03-27 14:41:26.815 : data event, bytes 800

如果我的数学不太好,8000 Hz 的 1 字节(8 位)(即 = 8000 bytes/s 数据)应该等于 400 bytes/50 毫秒?

查看了我得到的 800 个字节,它们看起来都是合法的,因为没有用零或类似的东西填充。

有人知道我哪里可能出错吗?

您实际上并未以 8 位捕获,因为您从未设置 WaveIn.WaveFormatWaveIn 对象将能够告诉您 WaveFormat 它正在捕获音频,默认情况下为 16 位。