Reputation: 149
basically, im looking for a way to simply input a mp3 file name , start time , end time and maybe a threshold value (as "silence" could be a relative term ?) and get the output on whether the mp3 file is silent or not within that input time period.
public static bool IsSilent(string audioFilePath, TimeSpan startTime , TimeSpan endTime, int? threshold)
{
//how to implement ?
}
any code or guidance is appreciated.
Upvotes: 1
Views: 456
Reputation: 49482
The simplest approach is to use an AudioFileReader
to get an ISampleProvider
allowing you to examine each sample as a floating point number in the range -1 to 1. Then take the absolute value of each sample (with Math.Abs
) and compare it to a threshold value. If any sample is above the threshold then that period is not silence.
Upvotes: 3