AudioCompressionManager

AudioCompressionManager

本文介绍了如何在c#中将wav pcm 44100转换为a-law 8bit mono的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我希望在我的c#项目中将pcm 44100 hz转换为witt ccitt a-law 8 bit mono 7 kb / s。 PLZ帮帮我一定要做什么?谢谢。

hii want convert pcm 44100 hz to wav ccitt a-law 8 bit mono 7 kb/s in my project in c# . plz help me what i must do ? thank you .

推荐答案

static void PcmToAlaw(string fileName)
{
    WaveReader wr = new WaveReader(File.OpenRead(fileName));
    IntPtr pcmFormat = wr.ReadFormat();
    FormatDetails[] fdArr = AudioCompressionManager.GetCompatibleFormatList(pcmFormat, true);
    foreach (FormatDetails fd in fdArr)
        {
        WaveFormat wf = AudioCompressionManager.GetWaveFormat(fd.FormatHandle);
        if (wf.wFormatTag == AudioCompressionManager.ALawFormatTag && wf.nChannels == 1)
        {
            IntPtr alawFormat = fd.FormatHandle;
            byte[] alawData = AudioCompressionManager.ToFormat(wr, alawFormat);
            WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"),
                AudioCompressionManager.FormatBytes(alawFormat));
            ww.WriteData(alawData);
            ww.Close();
            break;
        }
    }
}



这篇关于如何在c#中将wav pcm 44100转换为a-law 8bit mono的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 04:57