-
Notifications
You must be signed in to change notification settings - Fork 0
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
20 changed files
with
377 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "AbstractFilter.h" | ||
double AbstractFilter::sampleRate = 44100.0; |
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,32 @@ | ||
/* | ||
============================================================================== | ||
Filter.h | ||
Created: 5 Jul 2020 7:20:18pm | ||
Author: August | ||
============================================================================== | ||
*/ | ||
|
||
#pragma once | ||
class AbstractFilter | ||
{ | ||
public: | ||
AbstractFilter() : OldFreq(0.0), OldRes(0.0) | ||
{ } | ||
~AbstractFilter() | ||
{} | ||
inline static void SetSampleRate(double Rate) { sampleRate = Rate; }; | ||
void UpdateValues(double CutOff, double Res) | ||
{ | ||
if (CutOff == OldFreq && Res == OldRes) return; | ||
OldFreq = CutOff; OldRes = Res; | ||
UpdateParameters(CutOff, Res); | ||
} | ||
private: | ||
double OldFreq; | ||
double OldRes; | ||
protected: | ||
virtual void UpdateParameters(double CutOff, double Res) = 0; | ||
static double sampleRate; | ||
}; |
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
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,30 @@ | ||
/* | ||
============================================================================== | ||
NarrowBand.cpp | ||
Created: 26 Jun 2020 6:56:00pm | ||
Author: August | ||
============================================================================== | ||
*/ | ||
|
||
#include "NarrowBand.h" | ||
|
||
void NarrowBand::UpdateParameters(double CutOff, double Res)//Here the res actually controls the band width. This is a band reject filter | ||
{ | ||
double Freq = CutOff / sampleRate; | ||
if (Freq > 0.5) Freq = 0.5; if (Freq < 0.0) Freq = 0.0; | ||
double BW = 1.0 / (2.0 * Res); | ||
if (BW < 0.0) BW = 0.0; if (BW > 0.5) BW = 0.5; | ||
|
||
double CPF = 2.0 * cos(TWO_PI * Freq); | ||
double R = 1.0 - (3.0 * BW); | ||
double R2 = R * R; | ||
double K = (1.0 - (R * CPF) + R2) / (2.0 - CPF); | ||
|
||
aCoefs[0] = 1.0-K; | ||
aCoefs[1] = (K-R) * CPF; | ||
aCoefs[2] = R2-K; | ||
bCoefs[0] = R * CPF; | ||
bCoefs[1] = -R2; | ||
} |
Oops, something went wrong.