My coder Vic converted Ian's code to C# for me to use.
thought I'd contribute also for all the C# guys out there.........

/// <summary>
/// Get file silence length
/// </summary>
/// <param name="file">file name</param>
/// <param name="threshold">threshold</param>
/// <returns>Point(-1, -1) on error or Point(start, end) </returns>
System.Windows.Point GetSilenceLength(string file, int threshold)
{
short[] buf = new short[50000];
long count = 0;
int chan = 0;
long pos = 0;
System.Windows.Point rc = new System.Windows.Point(-1, -1);
try
{
chan = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_STREAM_DECODE);
if (chan == 0)
{
Utils.LogWrite(LogEventType.Error, string.Format("GetSilenceLength: Couldn't create BASS stream (error = %{0})", Bass.BASS_ErrorGetCode()));
return rc;
}
while (Bass.BASS_ChannelIsActive(chan) != BASSActive.BASS_ACTIVE_STOPPED)
{
int a;
int b = Bass.BASS_ChannelGetData(chan, buf, 20000); // decode some data
b /= 2; // bytes -> samples
for (a = 0; a < b && Math.Abs(buf[a]) <= threshold; a++)
; // count silent samples
count += a * 2; // add number of silent bytes
if (a < b)
{
// sound has begun!
// move back to a quieter sample (to avoid "click")
for (; (a != 0) && Math.Abs(buf[a]) > threshold / 4; a--,count-=2) ;
break;
}
}
rc.X = count;
pos = Bass.BASS_StreamGetFilePosition(chan, BASSStreamFilePosition.BASS_FILEPOS_END);
while (pos > count)
{
int a, b;
pos = (pos < 100000)? 0: pos - 100000; // step back a bit
Bass.BASS_ChannelSetPosition(chan,pos);
b = Bass.BASS_ChannelGetData(chan,buf,100000); // decode some data
b /= 2; // bytes -> samples
for (a = b; a > 0 && Math.Abs(buf[a - 1]) <= threshold / 2; a--)
; // count silent samples
if (a > 0)
{
// sound has begun!
count = pos + a * 2; // silence begins here
break;
}
}
rc.Y = count;
}
catch (Exception ex)
{
Utils.LogWrite(LogEventType.Error, "GetSilenceLength:" + ex.Message);
}
finally
{
if (chan != 0)
Bass.BASS_StreamFree(chan);
}
return rc;
}