Skip to content

Commit

Permalink
some documentation on LowpassFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
tebjan committed Apr 22, 2015
1 parent 4f1e56d commit 3d8598b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions common/src/core/Utils/Animation/LowpassFilter.cs
Expand Up @@ -7,6 +7,9 @@ namespace VVVV.Utils.Animation
/// </summary>
public class LowpassFilter
{
/// <summary>
/// Initialize the filter
/// </summary>
public LowpassFilter()
{
FFirstTime = true;
Expand All @@ -15,6 +18,9 @@ public LowpassFilter()
protected bool FFirstTime;
protected double FLastFilterValue;

/// <summary>
/// Last filter value
/// </summary>
public double Last
{
get
Expand All @@ -23,17 +29,23 @@ public double Last
}
}

public double Filter(double x, double alpha)
/// <summary>
/// Gets the next filter value, applies <c>alpha * value + (1 - alpha) * lastValue</c>
/// </summary>
/// <param name="value"></param>
/// <param name="alpha"></param>
/// <returns></returns>
public double Filter(double value, double alpha = 1)
{
double filterValue = 0;
if (FFirstTime)
{
FFirstTime = false;
filterValue = x;
filterValue = value;
}
else
{
filterValue = alpha * x + (1 - alpha) * FLastFilterValue;
filterValue = alpha * value + (1 - alpha) * FLastFilterValue;
}

FLastFilterValue = filterValue;
Expand Down

0 comments on commit 3d8598b

Please sign in to comment.