使用C#将WAV PCM压缩到Microsoft GSM 6.10音频编解码器

时间:2012-02-23 14:51:50

标签: c# gsm pcm

有没有人知道如何将PCM格式的未压缩wav文件转换为GSM 6.10 Audio Codec压缩的wav文件?

2 个答案:

答案 0 :(得分:2)

尝试How to convert to Gsm Wav file

    static void ToWavWithGsm()
    {
        string fileName = @"e:\Down\male.wav";
        WaveReader wr = new WaveReader(File.OpenRead(fileName));
        IntPtr format = wr.ReadFormat();
        IntPtr formatGsm = AudioCompressionManager.GetCompatibleFormat(format,
            AudioCompressionManager.Gsm610FormatTag);
        byte[] dataGsm = AudioCompressionManager.ToFormat(wr, formatGsm);
        WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"),
            AudioCompressionManager.FormatBytes(formatGsm));
        ww.WriteData(dataGsm);
        ww.Close();
        wr.Close();
    }

答案 1 :(得分:0)

IIRC,如果您安装了编解码器,naudio应该可以使用WaveFormatConversionStream进行编码