-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
347 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* These implementations are based on http://www.earlevel.com/main/2011/01/02/biquad-formulas/ | ||
*/ | ||
|
||
using System; | ||
|
||
namespace CSCore.DSP | ||
{ | ||
/// <summary> | ||
/// Used to apply a bandpass-filter to a signal. | ||
/// </summary> | ||
public class BandpassFilter : BiQuad | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BandpassFilter"/> class. | ||
/// </summary> | ||
/// <param name="sampleRate">The sample rate.</param> | ||
/// <param name="frequency">The filter's corner frequency.</param> | ||
public BandpassFilter(int sampleRate, double frequency) | ||
: base(sampleRate, frequency) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Calculates all coefficients. | ||
/// </summary> | ||
protected override void CalculateBiQuadCoefficients() | ||
{ | ||
double k = Math.Tan(Math.PI * Frequency / SampleRate); | ||
double norm = 1 / (1 + k / Q + k * k); | ||
A0 = k / Q * norm; | ||
A1 = 0; | ||
A2 = -A0; | ||
B1 = 2 * (k * k - 1) * norm; | ||
B2 = (1 - k / Q + k * k) * norm; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.