-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathFDUDC.h
More file actions
69 lines (63 loc) · 1.92 KB
/
Copy pathFDUDC.h
File metadata and controls
69 lines (63 loc) · 1.92 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
/*
* Digital up and down conversion with fractional sample rate conversion
*
*/
#if !defined(FDUDC_H)
#define FDUDC_H
#include <complex>
#include <functional>
#include <vector>
class CFDUDC {
public:
CFDUDC(
unsigned resampNum,
unsigned resampDen,
int rxIfNum,
unsigned rxIfDen,
int txIfNum,
unsigned txIfDen,
// Approximate length of the filter in downconverted samples.
// A higher value results in a narrower transition band
// but higher CPU use.
// Delay of the filter in downconverted samples
// is approximately half of this value.
unsigned length = 9,
// Cutoff frequency as a fraction of Nyquist frequency
// of downconverted sampler rate
float cutoff = 0.45f
);
~CFDUDC();
void process(
std::vector<std::complex<float>> &buffer,
std::function<std::complex<float>(std::complex<float>)> process_sample);
private:
// Numerator of sample rate ratio
// This determines the interpolation factor for DDC
// and decimation factor for DUC.
unsigned m_resampNum;
// Denominator of sample rate ratio.
// This determines the decimation factor for DDC
// and interpolation factor for DUC.
unsigned m_resampDen;
// Polyphase filter phase
unsigned m_p;
// Index to m_in and m_out
unsigned m_i;
// Index to m_ddc_sine
unsigned m_ddc_i;
// Index to m_duc_sine
unsigned m_duc_i;
// Input sample to DUC
std::complex<float> m_ducIn;
// Polyphase filter taps
std::vector<float> m_taps;
// Input buffer for DDC resampler
std::vector<std::complex<float>> m_in;
// Output buffer for DUC resampler
std::vector<std::complex<float>> m_out;
// Downconversion sine table
std::vector<std::complex<float>> m_ddc_sine;
// Upconversion sine table
std::vector<std::complex<float>> m_duc_sine;
};
#endif