-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathradio-constants.h
More file actions
executable file
·98 lines (88 loc) · 2.38 KB
/
radio-constants.h
File metadata and controls
executable file
·98 lines (88 loc) · 2.38 KB
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
#
/*
* Copyright (C) 2020
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Programming
*
* This file is part of the DRM+ Decoder
*
* DRM+ Decoder 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.
*
* DRM+ Decoder 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 DRM+ Decoder; 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
#define CURRENT_VERSION "0.8"
//
//
typedef std::complex<float> DSPCOMPLEX;
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)
// 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
std::complex<float> cmul (std::complex<float> x, float y) {
return std::complex<float> (real (x) * y, imag (x) * y);
}
static inline
std::complex<float> cdiv (std::complex<float> x, float y) {
return std::complex<float> (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