-
Notifications
You must be signed in to change notification settings - Fork 18
/
radio-constants.h
123 lines (107 loc) · 2.73 KB
/
radio-constants.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#
/*
* Copyright (C) 2011 .. 2017
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of ws radio
*
* sw radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* sw radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sw radio; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#
#ifndef __RADIO_CONSTANTS__
#define __RADIO_CONSTANTS__
#include <math.h>
#include <complex>
#include <stdint.h>
#include <limits>
#include <stdlib.h>
#include <unistd.h>
#ifdef __MINGW32__
#include "windows.h"
#else
#include "alloca.h"
#include "dlfcn.h"
typedef void *HINSTANCE;
#endif
//
//
typedef std::complex<float> DSPCOMPLEX;
#ifndef M_PI
# define M_PI 3.14159265358979323846 /* pi */
#endif
using namespace std;
#define Hz(x) (x)
#define Khz(x) (x * 1000)
#define KHz(x) (x * 1000)
#define kHz(x) (x * 1000)
#define Mhz(x) (Khz (x) * 1000)
#define MHz(x) (KHz (x) * 1000)
#define mHz(x) (KHz (x) * 1000)
/*
*/
#define MINIMUM(x, y) ((x) < (y) ? x : y)
#define MAXIMUM(x, y) ((x) > (y) ? x : y)
#define IandQ 0100
#define QandI 0101
#define I_Only 0102
#define Q_Only 0104
#define CURRENT_VERSION "8.1"
#define MSECFORTIMER 10
//
#define PILOTFILTER_SIZE 31
#define RDSLOWPASS_SIZE 89
#define HILBERT_SIZE 13
#define RDSBANDFILTER_SIZE 49
#define FFT_SIZE 256
#define PILOT_WIDTH 1000
#define RDS_WIDTH 1500
#define LEVEL_SIZE 512
#define LEVEL_FREQ 3
//
// common functions
static inline
bool isIndeterminate (float x) {
return x != x;
}
static inline
bool isInfinite (double x) {
return x == numeric_limits<float>::infinity ();
}
//
static inline
DSPCOMPLEX cmul (DSPCOMPLEX x, float y) {
return DSPCOMPLEX (real (x) * y, imag (x) * y);
}
static inline
DSPCOMPLEX cdiv (DSPCOMPLEX x, float y) {
return DSPCOMPLEX (real (x) / y, imag (x) / y);
}
static inline
float get_db (float x, int32_t y) {
return 20 * log10 ((x + 1) / (float)(y));
}
static inline
float PI_Constrain (float val) {
if (0 <= val && val < 2 * M_PI)
return val;
if (val >= 2 * M_PI)
return fmod (val, 2 * M_PI);
// apparently val < 0
if (val > - 2 * M_PI)
return val + 2 * M_PI;
return 2 * M_PI - fmod (- val, 2 * M_PI);
}
#endif