]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/fastrig.h
Bug fixes to jsdr, keyer
[dttsp.git] / jDttSP / fastrig.h
1 /* fastrig.h
2 This file is part of a program that implements a Software-Defined Radio.
3
4 Copyright (C) 2004 by Frank Brickle, AB2KT and Bob McGwier, N4HY
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20 The authors can be reached by email at
21
22 ab2kt@arrl.net
23 or
24 rwmcgwier@comcast.net
25
26 or by paper mail at
27
28 The DTTS Microwave Society
29 6 Kathleen Place
30 Bridgewater, NJ 08807
31 */
32
33 #ifndef _fastrig_h
34 #define _fastrig_h
35
36 #include <fromsys.h>
37 #include <banal.h>
38 #include <splitfields.h>
39 #include <datatypes.h>
40 #include <bufvec.h>
41
42 #ifdef notdef
43 #include <cxops.h>
44 #endif
45
46 #define SIN_TABLE_SIZE 4096
47 #define SIN_TABLE_SIZE_M1 4095
48
49 /* ********************************************** 
50  * TRIG_SPEED: 
51  * 0 = normal (slow); 
52  * 1 = table look up with interpolation (medium);
53  * 2 = table look up (fast) 
54  * ***********************************************/
55
56 /* Interpolation is ALWAYS done on atan2.  The setting
57    only applies to sin and cos */
58
59 #ifndef TRIG_SPEED
60 #define TRIG_SPEED 0
61 #endif
62
63 #if (TRIG_SPEED == 2)
64 #define SIN(x)     fast_sin(x)
65 #define COS(x)     fast_cos(x)
66 #define ATAN2(x,y) fast_atan2((x),(y))
67
68 #elif (TRIG_SPEED == 1)
69
70 #define SIN(x)     fast_sin(x)
71 #define COS(x)     fast_cos(x)
72 #define ATAN2(x,y) fast_atan2((x),(y))
73
74 #elif (TRIG_SPEED == 0)
75
76 #define SIN(x)     (REAL)sin((REAL)x)
77 #define COS(x)     (REAL)cos((REAL)x)
78 #define ATAN2(x,y) (REAL)atan2((REAL)(x),(REAL)(y))
79
80 #endif
81
82 #ifndef PI
83 #define PI M_PI
84 #endif /* PI */
85
86 #ifndef TWOPI
87 #define TWOPI    (2.0 * PI)
88 #endif
89
90 #ifndef ONE_OVER_TWOPI
91 #define ONE_OVER_TWOPI (0.159154943091895)
92 #endif
93
94 #if (TRIG_SPEED != 0)
95
96 extern void InitSPEEDTRIG(void);
97 extern REAL fast_sin(REAL);
98 extern REAL fast_cos(REAL);
99 extern REAL fast_atan2(REAL, REAL);
100
101 #endif
102 #endif