This project has moved. For the latest updates, please go here.

How to detect silence?

Nov 19, 2015 at 6:30 AM
Good day!
Can NAudio detect silence with some simple Api way?
Or, may be some peace of code.

Thank you!
Nov 21, 2015 at 9:51 PM
Easiest way is probably to check each sample processed for being 0 = silence.

E.g. create a custom SampleProvider that raises an event each time a sample passed is zero.
Dec 9, 2015 at 3:46 PM
I want to save the captured mic sound to different wave files by splitting the sound by silence
  1. Can I identify the silence immediately, once volume samples become 0 or do I need to check the 0 for some period of time (ex 2 sec silence time)?
  2. What is the best way to identify the silence, when there are background noise?
Thank you.
Dec 10, 2015 at 10:36 AM
1) Yes, you should check for at least some ms of audio. Because from time to time audio contains some zero crossings that would lead to false detection.
2) Either filter out the noise (e. g. cut a specified peak amaount) or calculate it in. As (white) noise contains all frequencies, you can´t easily filter out out by an eq or sth.
Dec 14, 2015 at 4:27 AM
Thank you for reply.
Is there any libraries for filter noise?
Dec 14, 2015 at 11:43 AM
I don´t know any .NET based.

But perhaps you can achive better results when you reduce overall volume by ~10-20% (which would discard some audio information as well). Anyway not possible without certain quality loss.