开发者

How to use Alvas.Audio to detect any sounds?

I have a problem with start to code my app. How I can detect sounds provided to my microphone using Alvas.Audio library? Could anyone provide me a sample code (i don't know how to use bulit-in function in that librar开发者_开发知识库y)?


See AudioCompressionManager.CheckSilent method

        private static void SkipSilent(string fileName, short silentLevel)
        {
            WaveReader wr = new WaveReader(File.OpenRead(fileName));
            IntPtr format = wr.ReadFormat();
            WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"), AudioCompressionManager.FormatBytes(format));
            int i = 0;
            while (true)
            {
                byte[] data = wr.ReadData(i, 1);
                if (data.Length == 0)
                {
                    break;
                }
                if (!AudioCompressionManager.CheckSilent(format, data, silentLevel))
                {
                    ww.WriteData(data);
                }
            }
            ww.Close();
            wr.Close();
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜