Darek
Darek

Reputation: 51

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 library)?

Upvotes: 3

Views: 586

Answers (1)

user595809
user595809

Reputation:

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

Upvotes: 1

Related Questions