Skip to content

Commit

Permalink
Update NoiseRemoval_Briggs.cs
Browse files Browse the repository at this point in the history
Issue #370 Fix bug where window was longer than the matrix.
  • Loading branch information
towsey authored and atruskie committed Oct 14, 2020
1 parent bbdedfd commit 5f0ddbe
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/AudioAnalysisTools/DSP/NoiseRemoval_Briggs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,24 @@ public static double[] CalculateLocalVariance1(double[] data, int window)
/// </summary>
public static double[] CalculateLocalVariance2(double[,] matrix, int colId, int rowWindow)
{
int rowCount = matrix.GetLength(0);
int colCount = matrix.GetLength(1);

if (rowWindow < 3)
{
throw new Exception("Invalid value for length of rowWindow. Must be >= 3");
}

if (rowWindow > rowCount)
{
rowWindow = rowCount - 1;
}

// the column window must be an odd number.
int colWindow = 5;
int halfColWindow = colWindow / 2;
int halfRowWindow = rowWindow / 2;

int rowCount = matrix.GetLength(0);
int colCount = matrix.GetLength(1);

double[] variances = new double[rowCount];

// set up the column Ids.
Expand Down

0 comments on commit 5f0ddbe

Please sign in to comment.