使用Naudio将Wave文件编码到G.722

时间:2017-09-04 19:06:41

标签: c# audio naudio rtp

我有C#RTP应用程序,我可以毫无问题地发送G.711编码音频 现在我正在尝试使用Naudio添加G.722支持。

此方法有效,但噪音太大

public byte[] Encode(byte[] data, int offset, int length)
    {
        G722Codec codec = new G722Codec();
        int bitrate = 64000; //Bits per sample = 8
        G722CodecState encoderState = new G722CodecState(bitrate, G722Flags.SampleRate8000);

        if (offset != 0)
        {
            throw new ArgumentException("G722 does not yet support non-zero offsets");
        }

        var wb = new WaveBuffer(data);
        int encodedLength = length/2;
        var outputBuffer = new byte[encodedLength];
        int encoded = codec.Encode(encoderState, outputBuffer, wb.ShortBuffer, length/2);
        return outputBuffer;
    }

如果我将流采样率更改为16k或22k,则根本无法正常工作。

有什么想法吗?

0 个答案:

没有答案
相关问题