Alvas.Audio Class Library

AudioCompressionManager.CheckSilent Method 

Checks the level of audio signal. If it is above silentLevel returns false otherwise it returns true.

[Visual Basic]
Public Shared Function CheckSilent( _
   ByVal format As IntPtr, _
   ByVal data As Byte(), _
   ByVal silentLevel As Short _
) As Boolean
[C#]
public static bool CheckSilent(
   IntPtr format,
   Byte[] data,
   Int16 silentLevel
);

Parameters

format
audio format
data
audio data
silentLevel
Can be in the range 0 .. short.MaxValue

Return Value

Example

This example shows simple using of 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();
}
 

See Also

AudioCompressionManager Class | Alvas.Audio Namespace