This repository has been archived by the owner on Oct 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkfilter.h
62 lines (50 loc) · 1.8 KB
/
mkfilter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* mkfilter -- given n, compute recurrence relation
to implement Butterworth, Bessel or Chebyshev filter of order n
A.J. Fisher, University of York <[email protected]>
September 1992 */
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#include <string.h>
/* Header file */
#define global
#define unless(x) if(!(x))
#define until(x) while(!(x))
#define VERSION "4.6"
#undef PI
#define PI 3.14159265358979323846 /* Microsoft C++ does not define M_PI ! */
#define TWOPI (2.0 * PI)
#define EPS 1e-10
#define MAXORDER 10
#define MAXPZ 512 /* .ge. 2*MAXORDER, to allow for doubling of poles in BP filter;
high values needed for FIR filters */
#define MAXSTRING 256
typedef void (*proc)();
typedef unsigned int uint;
extern "C"
{ double atof(const char*);
int atoi(char*);
void exit(int);
};
extern const char *progname;
extern void readdata(char*, double&, int&, double*, int&, double*);
inline double sqr(double x) { return x*x; }
inline bool seq(char *s1, char *s2) { return strcmp(s1,s2) == 0; }
inline bool onebit(uint m) { return (m != 0) && ((m & m-1) == 0); }
inline double asinh(double x)
{ /* Microsoft C++ does not define */
return log(x + sqrt(1.0 + sqr(x)));
}
inline double fix(double x)
{ /* nearest integer */
return (x >= 0.0) ? floor(0.5+x) : -floor(0.5-x);
}