Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting audio silence in WAV files using C#

Tags:

c#

.net

audio

I'm tasked with building a .NET client app to detect silence in a WAV files.

Is this possible with the built-in Windows APIs? Or alternately, any good libraries out there to help with this?

like image 945
Judah Gabriel Himango Avatar asked Aug 21 '08 04:08

Judah Gabriel Himango


People also ask

How can I detect silence in audio files?

The Detect Silence function allows you to search for silent sections in an event, and to split the event, removing the silent parts from the project, or to create regions corresponding to the non-silent sections.

How do I listen to waveforms?

In Windows 10, WAVs play by default in Windows Media Player. In macOS, they play by default in iTunes. If you're using Linux, you'll have to install a player to open WAV files—VLC is a great choice. All you have to do is double-click on the WAV file, and your default audio player will open the file and start playing.


1 Answers

Audio analysis is a difficult thing requiring a lot of complex math (think Fourier Transforms). The question you have to ask is "what is silence". If the audio that you are trying to edit is captured from an analog source, the chances are that there isn't any silence... they will only be areas of soft noise (line hum, ambient background noise, etc).

All that said, an algorithm that should work would be to determine a minimum volume (amplitude) threshold and duration (say, <10dbA for more than 2 seconds) and then simply do a volume analysis of the waveform looking for areas that meet this criteria (with perhaps some filters for millisecond spikes). I've never written this in C#, but this CodeProject article looks interesting; it describes C# code to draw a waveform... that is the same kind of code which could be used to do other amplitude analysis.

like image 138
Simon Gillbee Avatar answered Oct 03 '22 18:10

Simon Gillbee