/
burstmskdemodulator.h
220 lines (161 loc) · 4.58 KB
/
burstmskdemodulator.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#ifndef BURSTMSKDEMODULATOR_H
#define BURSTMSKDEMODULATOR_H
#include <QIODevice>
#include "DSP.h"
#include <QVector>
#include <complex>
#include <QPointer>
#include <QElapsedTimer>
#include "aerol.h"
#include "fftrwrapper.h"
typedef FFTrWrapper<double> FFTr;
typedef std::complex<double> cpx_type;
class CoarseFreqEstimate;
class BurstMskDemodulator : public QIODevice
{
Q_OBJECT
public:
enum ScatterPointType{ SPT_constellation, SPT_phaseoffseterror, SPT_phaseoffsetest, SPT_None};
struct Settings
{
int coarsefreqest_fft_power;
double freq_center;
double lockingbw;
double fb;
double Fs;
int symbolspercycle;
double signalthreshold;
Settings()
{
coarsefreqest_fft_power=13;//2^coarsefreqest_fft_power
freq_center=1000;//Hz
lockingbw=500;//Hz
fb=125;//bps
Fs=8000;//Hz
symbolspercycle=16;
signalthreshold=0.6;
}
};
explicit BurstMskDemodulator(QObject *parent);
~BurstMskDemodulator();
void ConnectSinkDevice(QIODevice *datasinkdevice);
void DisconnectSinkDevice();
void start();
void stop();
qint64 readData(char *data, qint64 maxlen);
qint64 writeData(const char *data, qint64 len);
void setSettings(Settings settings);
void invalidatesettings();
void setAFC(bool state);
void setSQL(bool state);
void setScatterPointType(ScatterPointType type);
double getCurrentFreq();
private:
WaveTable mixer_center;
WaveTable mixer2;
bool sql;
int spectrumnfft,bbnfft;
QVector<double> spectrumcycbuff;
QVector<double> spectrumtmpbuff;
int spectrumcycbuff_ptr;
double Fs;
double freq_center;
double lockingbw;
double fb;
double symbolspercycle;
double signalthreshold;
double SamplesPerSymbol;
FIR *matchedfilter_re;
FIR *matchedfilter_im;
AGC *agc;
AGC *agc2;
MSKEbNoMeasure *ebnomeasure;
MovingAverage *pointmean;
QVector<cpx_type> pointbuff;
int pointbuff_ptr;
QList<int> tixd;
DiffDecode diffdecode;
QVector<short> RxDataBits;//unpacked
double mse;
MovingAverage *msema;
bool afc;
int scatterpointtype;
BaceConverter bc;
QPointer<QIODevice> pdatasinkdevice;
QElapsedTimer timer;
// trident detector stuff
//hilbert
QJHilbertFilter *hfir;
QVector<kffsamp_t> hfirbuff;
//delay lines
Delay< std::complex<double> > bt_d1;
Delay< double > bt_ma_diff;
//MAs
TMovingAverage< std::complex<double> > bt_ma1;
MovingAverage *mav1;
//Peak detection
PeakDetector pdet;
//delay for peak detection alignment
DelayThing< std::complex<double> > d1;
//delay for trident detection
DelayThing<double> d2;
//trident shape thing
QVector<double> tridentbuffer;
int tridentbuffer_ptr;
int tridentbuffer_sz;
int maxvalbin = 0;
double trackfreq = 0;
//fft for trident
FFTr *fftr;
QVector<cpx_type> out_base,out_top;
QVector<double> out_abs_diff;
QVector<double> in;
double maxval;
double vol_gain;
int cntr;
int startstopstart;
int startstop;
int numPoints;
const cpx_type imag=cpx_type(0, 1);
WaveTable st_osc;
WaveTable st_osc_filter;
WaveTable st_osc_ref;
WaveTable st_osc_quarter;
Delay<double> a1;
double ee;
cpx_type symboltone_averotator;
cpx_type symboltone_rotator;
double carrier_rotation_est;
cpx_type pt_d;
cpx_type pt_last;
cpx_type rotator;
double rotator_freq;
bool even;
//st
Delay<double> delays;
Delay<double> delayt41;
Delay<double> delayt42;
Delay<double> delayt8;
IIR st_iir_resonator;
int yui;
int endRotation;
int startProcessing;
signals:
void ScatterPoints(const QVector<cpx_type> &buffer);
void SymbolPhase(double phase_rad);
void BBOverlapedBuffer(const QVector<cpx_type> &buffer);
void OrgOverlapedBuffer(const QVector<double> &buffer);
void Plottables(double freq_est,double freq_center,double bandwidth);
void PeakVolume(double Volume);
void RxData(QByteArray &data);//packed in bytes
void MSESignal(double mse);
void SignalStatus(bool gotasignal);
void WarningTextSignal(const QString &str);
void EbNoMeasurmentSignal(double EbNo);
void SampleRateChanged(double Fs);
void BitRateChanged(double fb,bool burstmode);
void processDemodulatedSoftBits(const QVector<short> &soft_bits);
public slots:
void CenterFreqChangedSlot(double freq_center);
};
#endif // BURSTMSKDEMODULATOR_H