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();
}
精彩评论