This project has moved and is read-only. For the latest updates, please go here.

Detect digital silence in a wave file

Feb 2, 2013 at 7:01 PM

my today's questions is how to detect digital silence (without noise, pure digital silence) in a (large) wave file and split it into pieces.

As an example (--- means digital silence):

Input wave: ----ABCDEFG------HIJKLMN----OPQR---
Output wave files:

Thank you very much for your great work!
Feb 4, 2013 at 11:09 AM
You would need to examine each sample individually. A series of consecutive zero values would indicate a period of silence. Then you can copy bits between silence into new wave files using WaveFileWriter.
Feb 4, 2013 at 1:01 PM
Thank you Mark!

Could you tell me where I can find an example on how to read a wave file sample by sample?

Again, thank you very much for your help.
Feb 11, 2013 at 3:16 PM
You have to use the BitConverter class to turn the raw bytes into samples. If you are using the very latest NAudio code, you can make use of ReadNextSampleFrame on the WaveFileReader class, which improves on TryReadFloat (which only worked on mono audio files), which simplifies getting samples as floating point values.