Skip to content

Commit

Permalink
Update ActivityAndCover.cs
Browse files Browse the repository at this point in the history
Issue #331 Change bug in calculation of index: activity
  • Loading branch information
towsey authored and atruskie committed Jul 30, 2020
1 parent 115b610 commit 055571e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/AudioAnalysisTools/ActivityAndCover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public SpectralActivity(double[] eventSp, double[] coverSp, double lowFreqCvr, d

public static class ActivityAndCover
{
public const double DefaultActivityThresholdDb = 6.0; // used to select frames that have 3dB > background
public const double DefaultActivityThresholdDb = 6.0; // used to select frames having dB value above background

public static SummaryActivity CalculateActivity(double[] dBarray, TimeSpan frameStepDuration)
{
Expand All @@ -80,20 +80,17 @@ public static SummaryActivity CalculateActivity(double[] dBarray, TimeSpan frame
/// </summary>
/// <param name="dBarray">array of DB values.</param>
/// <param name="frameStepDuration">frame duration in seconds.</param>
/// <param name="dbThreshold">thrshold in decibels.</param>
/// <param name="dbThreshold">threshold in decibels.</param>
public static SummaryActivity CalculateActivity(double[] dBarray, TimeSpan frameStepDuration, double dbThreshold)
{
// minimum frame length for recognition of a valid event
//int minFrameCount = (int)Math.Round(ActivityAndCover.DEFAULT_MinimumEventDuration.TotalMilliseconds / frameStepDuration.TotalMilliseconds);

bool[] activeFrames = new bool[dBarray.Length];
double activeAvDecibels = 0.0;
int activeFrameCount = 0;

// get frames with activity >= threshold dB above background and count
for (int i = 0; i < dBarray.Length; i++)
{
if (dBarray[i] >= DefaultActivityThresholdDb)
if (dBarray[i] >= dbThreshold)
{
activeFrames[i] = true;
activeAvDecibels += dBarray[i];
Expand Down

0 comments on commit 055571e

Please sign in to comment.