Fixes to filtering

This commit is contained in:
Ryzerth
2021-04-17 03:38:48 +02:00
parent 3bf4f0ce01
commit d1e553f05a
7 changed files with 45 additions and 39 deletions

View File

@@ -5,8 +5,8 @@
namespace dsp {
namespace math {
inline float sinc(float omega, float x, float norm) {
return (x == 0.0f) ? 1.0f : (sinf(omega*x)/(norm*x));
inline double sinc(double omega, double x, double norm) {
return (x == 0.0f) ? 1.0f : (sin(omega*x)/(norm*x));
}
}
}

View File

@@ -3,25 +3,25 @@
namespace dsp {
namespace window_function {
inline float blackman(float n, float N, float alpha = 0.16f) {
float a0 = (1.0f-alpha) / 2.0f;
float a2 = alpha / 2.0f;
return a0 - (0.5f*cosf(2.0f*FL_M_PI*(n/N))) + (a2*cosf(4.0f*FL_M_PI*(n/N)));
inline double blackman(double n, double N, double alpha = 0.16f) {
double a0 = (1.0f-alpha) / 2.0f;
double a2 = alpha / 2.0f;
return a0 - (0.5f*cos(2.0f*FL_M_PI*(n/N))) + (a2*cos(4.0f*FL_M_PI*(n/N)));
}
inline float blackmanThirdOrder(float n, float N, float a0, float a1, float a2, float a3) {
return a0 - (a1*cosf(2.0f*FL_M_PI*(n/N))) + (a2*cosf(4.0f*FL_M_PI*(n/N))) - (a3*cosf(6.0f*FL_M_PI*(n/N)));
inline double blackmanThirdOrder(double n, double N, double a0, double a1, double a2, double a3) {
return a0 - (a1*cos(2.0f*FL_M_PI*(n/N))) + (a2*cos(4.0f*FL_M_PI*(n/N))) - (a3*cos(6.0f*FL_M_PI*(n/N)));
}
inline float nuttall(float n, float N) {
inline double nuttall(double n, double N) {
return blackmanThirdOrder(n, N, 0.3635819f, 0.4891775f, 0.1365995f, 0.0106411f);
}
inline float blackmanNuttall(float n, float N) {
inline double blackmanNuttall(double n, double N) {
return blackmanThirdOrder(n, N, 0.3635819f, 0.4891775f, 0.1365995f, 0.0106411f);
}
inline float blackmanHarris(float n, float N) {
inline double blackmanHarris(double n, double N) {
return blackmanThirdOrder(n, N, 0.35875f, 0.48829f, 0.14128f, 0.01168f);
}
}