-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathIQ16.h
47 lines (36 loc) · 1.01 KB
/
IQ16.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
#ifndef _IQ16_GUARD
#define _IQ16_GUARD
//#define CHECKNOMACRO
#define TAU INT16_MAX * 2
typedef struct IQPair
{
int16_t i;
int16_t q;
} IQPair;
#define IQPAIR_SCALAR_QUOTIENT(x, y) ((IQPair) {.i=x.i/y, .q=x.q/y})
#ifdef CHECKNOMACRO
IQPair complex_conjugate(IQPair arg);
IQPair complex_product(IQPair arg1, IQPair arg2);
#define IQPAIR_CONJUGATE complex_conjugate
#define IQPAIR_PRODUCT complex_product
#else
#define IQPAIR_CONJUGATE(x)\
((IQPair) {\
.q=x.q,\
.i=-x.i\
})
#define IQPAIR_PRODUCT(x, y)\
((IQPair) {\
.q=(x.q*y.q)-(x.i*y.i),\
.i=(x.q*y.i)+(x.i*y.q)\
})
#endif
typedef void (*SampleHandler)(IQPair sample);
typedef struct IQDecimatorS
{
uint32_t acci, accq;
uint16_t count, downsample;
SampleHandler samplehandler;
} IQDecimator;
void decimate(IQDecimator *d, IQPair sample);
#endif