How to use Alvas.Audio to detect any sounds?

I have a problem sending code for my application. How can I detect the sounds provided to my microphone using the Alvas.Audio library? Can someone provide me some sample code (I don't know how to use the bulit-in function in this library)?

+3
source share
1 answer

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

Source: https://habr.com/ru/post/1751221/


All Articles