Compress WAV PCM to Microsoft GSM 6.10 Audio Codec

2019-08-20 13:37发布

问题:

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?

回答1:

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


回答2:

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



标签: c# gsm pcm