检查wav格式编码

时间:2015-07-06 14:10:45

标签: c# wav

如何在C#应用程序中获取wav文件格式? 我的意思是.wav uLaw foramt编码wav文件。我怎么检查这个?

PCM和uLaw都具有相同的比特率值和KiB值。

8,000 Hz --- 8位PCM --- 64 --- 469
8,000 Hz ---μ-Law -------- 64 --- 469

3 个答案:

答案 0 :(得分:2)

您需要查看此article

/// <summary>
        /// Ensure any given wave file path that the file matches 
        /// with default or base format [16bit 8kHz Mono]
        /// </summary>
        /// <param name="strPath">Wave file path</param>
        /// <returns>True/False</returns>
        public bool Validate(string strPath)
        {
            if (strPath == null) strPath = "";
            if (strPath == "") return false;

            clsWaveProcessor wa_val = new clsWaveProcessor();
            wa_val.WaveHeaderIN(strPath);
            if (wa_val.BitsPerSample != BIT_PER_SMPL) return false;
            if (wa_val.Channels != CHNL) return false;
            if (wa_val.SampleRate != SMPL_RATE) return false;
            return true;
        }

        /// <summary>
        /// Compare two wave files to ensure both are in same format
        /// </summary>
        /// <param name="Wave1">ref. to processor object</param>
        /// <param name="Wave2">ref. to processor object</param>
        /// <returns>True/False</returns>
        private bool Compare(ref clsWaveProcessor Wave1, ref clsWaveProcessor Wave2)
        {
            if (Wave1.Channels != Wave2.Channels) return false;
            if (Wave1.BitsPerSample != Wave2.BitsPerSample) return false;
            if (Wave1.SampleRate != Wave2.SampleRate) return false;
            return true;
        }

答案 1 :(得分:0)

您可以打开文件(以二进制模式)并阅读标题。格式如下所述:http://www-mmsp.ece.mcgill.ca/documents/AudioFormats/WAVE/WAVE.html

答案 2 :(得分:0)

这是Radiodef在堆栈溢出的Java方面的精彩回答。 How do I use audio sample data from Java Sound?

以下是字节的布局方式http://www.topherlee.com/software/pcm-tut-wavformat.html

希望有所帮助!

相关问题