views:

89

answers:

2

Hi, I'm hoping you can help me with a program I'm trying to write in VB.NET.

I have a standard WMA stream, streaming in constantly via the internet. I need to write an application to stream this audio, and looks for any periods of 'silence'. When it detects silence, it runs an event.

For the purposes of this, silence is defined as three seconds of zero-level audio. The stream keeps going in a technical sense, but there is no audible noise coming through it.

However, I want the program to detect the silence while it is still in the 'buffer'. That is, the user won't hear this silence before the program detects it is there.

The audio shouldn't stop as it is analysing this silence - it needs to keep playing the audio constantly to the user.

I'm open to using whatever suitable API is out there - such as BASS, or the Windows Media extensions built into the dot net platform.

Thanks!!

+1  A: 

If you have the PCM data you can just take an average of a few samples and if it's below a threshold consider it silence. I assume if you're playing the audio you have access to the uncompressed data.

Unfortunately I don't know the details of the WMA codec, but I think the easiest way would be to just take the average of a few samples.

Nathan
A: 

Well, I am doing exactly this in my product: have multiple internet audio streams captured and decoded to PCM, and then various analysis performed on them, one of them beeing silence detection.

If you want to create something like it yourself, use Windows Media Format SDK for .net from here:

http://windowsmedianet.sourceforge.net/

Then, use IWMReader and it's OnSample callback that will provide PCM data for you.

Then, calculate maximum input levels for small buffers, see that level for 3 seconds and if it's below your treshold, fire an event.

Daniel Mošmondor