c#压缩WAV PCM到微软GSM 6.10音频编解码器。

时间:2022-05-08 19:42:43

Does any one know how to convert a uncompressed wave file in PCM format to a wav file compressed in GSM 6.10 Audio Codec?

有没有人知道如何将一个未压缩的wave文件转换成一个wav文件压缩在GSM 6.10音频编解码器?

2 个解决方案

#1


2  

Try How to convert to Gsm Wav file

尝试如何转换为Gsm Wav文件。

    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();
    }

#2


0  

IIRC, if you have the codec installed, naudio should be able to encode with it using WaveFormatConversionStream

IIRC,如果你安装了codec, naudio应该可以用它来对它进行编码。

#1


2  

Try How to convert to Gsm Wav file

尝试如何转换为Gsm Wav文件。

    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();
    }

#2


0  

IIRC, if you have the codec installed, naudio should be able to encode with it using WaveFormatConversionStream

IIRC,如果你安装了codec, naudio应该可以用它来对它进行编码。