kwave  18.07.70
LowPassFilter.cpp File Reference
#include "config.h"
#include <complex>
#include <math.h>
#include "LowPassFilter.h"
Include dependency graph for LowPassFilter.cpp:

Go to the source code of this file.

Macros

#define SPN   0.00001
 

Functions

static void shelve (double cf, double boost, double *a0, double *a1, double *a2, double *b1, double *b2)
 

Macro Definition Documentation

◆ SPN

#define SPN   0.00001

Definition at line 66 of file LowPassFilter.cpp.

Referenced by shelve().

Function Documentation

◆ shelve()

static void shelve ( double  cf,
double  boost,
double *  a0,
double *  a1,
double *  a2,
double *  b1,
double *  b2 
)
static

Definition at line 68 of file LowPassFilter.cpp.

References SPN.

Referenced by Kwave::LowPassFilter::normed_setfilter_shelvelowpass().

71 {
72  double a, A, F, tmp, b0, recipb0, asq, F2, gamma2, siggam2, gam2p1;
73  double gamman, gammad, ta0, ta1, ta2, tb0, tb1, tb2, aa1, ab1;
74 
75  a = tan(M_PI * (cf - 0.25));
76  asq = a * a;
77  A = pow(10.0, boost / 20.0);
78  if ((boost < 6.0) && (boost > -6.0)) F = sqrt(A);
79  else if (A > 1.0) F = A / sqrt(2.0);
80  else F = A*sqrt(2.0);
81 
82  F2 = F * F;
83  tmp = A * A - F2;
84  if (fabs(tmp) <= SPN) gammad = 1.0;
85  else gammad = pow((F2 - 1.0) / tmp, 0.25);
86  gamman = sqrt(A) * gammad;
87 
88  gamma2 = gamman * gamman;
89  gam2p1 = 1.0 + gamma2;
90  siggam2 = 2.0 * sqrt(2.0) / 2.0 * gamman;
91  ta0 = gam2p1 + siggam2;
92  ta1 = -2.0 * (1.0 - gamma2);
93  ta2 = gam2p1 - siggam2;
94 
95  gamma2 = gammad * gammad;
96  gam2p1 = 1.0 + gamma2;
97  siggam2 = 2.0 * sqrt(2.0) / 2.0 * gammad;
98  tb0 = gam2p1 + siggam2;
99  tb1 = -2.0 * (1.0 - gamma2);
100  tb2 = gam2p1 - siggam2;
101 
102  aa1 = a * ta1;
103  *a0 = ta0 + aa1 + asq * ta2;
104  *a1 = 2.0 * a * (ta0 + ta2) + (1.0 + asq) * ta1;
105  *a2 = asq * ta0 + aa1 + ta2;
106 
107  ab1 = a * tb1;
108  b0 = tb0 + ab1 + asq * tb2;
109  *b1 = 2.0 * a * (tb0 + tb2) + (1.0 + asq) * tb1;
110  *b2 = asq * tb0 + ab1 + tb2;
111 
112  recipb0 = 1.0 / b0;
113  *a0 *= recipb0;
114  *a1 *= recipb0;
115  *a2 *= recipb0;
116  *b1 *= recipb0;
117  *b2 *= recipb0;
118 }
#define SPN
Here is the caller graph for this function: