Skip to content

Commit

Permalink
prevent NAN clipping in Filter. fixes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
joreg committed Nov 24, 2023
1 parent 136f022 commit 404683b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deployment/VL.Audio.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>VL.Audio</id>
<version>1.3.2-preview</version>
<version>1.3.3-preview</version>
<title>VL.Audio</title>
<authors>NAudio, vvvv</authors>
<owners>vvvv</owners>
Expand Down
14 changes: 10 additions & 4 deletions src/Signals/Filters/AnalogModelingFilterSignal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,19 @@ void MoogLadder(float[] buffer, int offset, int count)
y4 = y3 * p + oldy3 * p - k * y4;
//Clipper band limited sigmoid
y4 -= (y4 * y4 * y4) / 6.0f;

//prevent NAN clipping when input signal is too loud
x = !float.IsNaN(x) ? x : 0;
y1 = !float.IsNaN(y1) ? y1 : 0;
y2 = !float.IsNaN(y2) ? y2 : 0;
y3 = !float.IsNaN(y3) ? y3 : 0;
y4 = !float.IsNaN(y4) ? y4 : 0;

oldx = x;
oldy1 = y1;
oldy2 = y2;
oldy3 = y3;

switch (FilterType.Value)
{
case AnalogModelingFilterType.LowPass:
Expand All @@ -279,6 +287,4 @@ void MoogLadder(float[] buffer, int offset, int count)
}

}
}


}

0 comments on commit 404683b

Please sign in to comment.