-
Notifications
You must be signed in to change notification settings - Fork 17
/
radio.h
289 lines (258 loc) · 7.34 KB
/
radio.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#
/*
* Copyright (C) 2012 .. 2024
* Jan van Katwijk ([email protected])
* Lazy Chair Computing
*
* This file is part of the SDR-J-FM
*
* SDR-J-FM 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.
*
* SDR-J-FM 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 SDR-J-FM; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#pragma once
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QWidget>
#include <QDialog>
#include <QInputDialog>
#include <QLineEdit>
#include <QQueue>
#include <QTimer>
#include <QWheelEvent>
#include <qwt.h>
#include <sndfile.h>
#include "fm-constants.h"
#include "fm-processor.h"
#include "iqdisplay.h"
#include "ringbuffer.h"
#include "iqdisplay.h"
#include "ui_radio.h"
#include "rds-decoder.h"
#include <atomic>
#include "popup-keypad.h"
#include "fm-demodulator.h"
#include "ui_configwidget.h"
class QSettings;
class fmProcessor;
class rdsDecoder;
class hs_scope;
class ls_scope;
class audioSink;
class deviceHandler;
class programList;
class ThemeChoser;
#define IQ_SCOPE_SIZE 64
constexpr int PROGRAM_RESTART_EXIT_CODE = -1234; // value is arbitrary
/*
* The main gui object. It inherits from
* QDialog and the generated form
*/
class RadioInterface : public QDialog,
private Ui_sdr_j_fm {
Q_OBJECT
public:
RadioInterface (QSettings *,
QString,
ThemeChoser *,
int32_t,
QWidget *parent = nullptr);
~RadioInterface ();
private:
RingBuffer<std::complex<float>> iqBuffer;
RingBuffer<std::complex<float>> hfBuffer;
RingBuffer<std::complex<float>> lfBuffer;
fm_Demodulator theDemodulator;
IQDisplay *iqScope;
// Processing modes
enum class ERunStates {
IDLE = 0100,
PAUSED = 0101,
RUNNING = 0102,
STOPPING = 0103
};
ThemeChoser *themeChooser;
bool ExtioLock;
int16_t outputDevice;
void localConnects ();
void dumpControlState (QSettings *);
Ui_configWidget configWidget;
QFrame configDisplay;
hs_scope *hfScope;
ls_scope *lfScope;
//
keyPad mykeyPad;
QTimer autoIncrementTimer;
QTimer displayTimer;
QSettings *fmSettings;
int32_t inputRate;
int32_t fmRate;
int32_t workingRate;
int32_t audioRate;
int16_t displaySize;
int16_t rasterSize;
int16_t spectrumSize;
int32_t averageCount;
int16_t repeatRate;
audioSink *our_audioSink;
int8_t channelSelector;
deviceHandler *theDevice;
std::vector<int16_t> outTable;
uint8_t HFviewMode;
uint8_t inputMode;
float attValueL;
float attValueR;
int32_t fmBandwidth;
int32_t loFrequency;
int32_t currentFreq;
QString footText ();
void restoreGUIsettings (QSettings *);
int32_t mapIncrement (int32_t);
int32_t incrementInterval (int16_t);
void displayFrequency (int32_t);
int16_t incrementIndex;
int32_t autoIncrement_amount;
int32_t fmIncrement;
int32_t minLoopFrequency;
int32_t maxLoopFrequency;
void incrementFrequency (int32_t);
void set_incrementFlag (int16_t);
void stopIncrementing ();
void stop_lcdTimer ();
/*
* dumping
*/
bool sourceDumping;
SNDFILE *dumpfilePointer;
bool audioDumping;
SNDFILE *audiofilePointer;
fmProcessor *myFMprocessor;
int32_t currentPIcode;
int32_t frequencyforPICode;
int16_t logTime;
FILE *logFile;
bool setupSoundOut (QComboBox *, audioSink *,
int32_t,
std::vector<int16_t> &);
void setup_HFScope ();
void setup_LFScope ();
bool squelchMode;
void resetSelector ();
// int32_t mapRates (int32_t);
void abortSystem (int);
void TerminateProcess ();
void make_newProcessor ();
deviceHandler *getDevice (const QString &);
deviceHandler *setDevice (QSettings *);
//
// added or modified
bool afcActive;
float afcAlpha;
int32_t afcCurrOffFreq;
float peakLeftDamped;
float peakRightDamped;
//
// end added
void reset_afc ();
int32_t setTuner (int32_t);
rdsDecoder::ERdsMode rdsModus;
std::atomic<ERunStates> runMode;
void setup_IQPlot ();
QLineEdit myLine;
programList *myProgramList;
/*
* The private slots link the GUI elements
* to the GUI code
*/
private slots:
void setStart ();
void updateTimeDisplay ();
void handle_pauseButton ();
void setIQBalance (int);
void autoIncrement_timeout ();
void handle_StreamOutSelector (int);
void handle_dumpButton ();
void handle_audioDumpButton ();
void handle_configButton ();
void handle_fmFilterSelect (const QString &);
void handle_fmModeSelector (const QString &);
void handle_fmRdsSelector (const QString &);
void handle_fmDecoderSelector (const QString &);
void handle_fmChannelSelector (const QString &);
void handle_fmDeemphasis (const QString &);
void handle_fmLFcutoff (const QString &);
void handle_fc_plus ();
void handle_fc_min ();
void handle_fm_increment (int);
void handle_minimumSelect (int);
void handle_maximumSelect (int);
void handle_f_plus ();
void handle_f_min ();
void handle_squelchSlider (int);
void handle_squelchSelector (const QString &);
void handle_freqSaveButton ();
void handle_myLine ();
void handle_loggingButton (const QString &);
void handle_logSavingButton ();
void handle_afcSelector (int);
void handle_AudioGainSlider (int n);
void handle_fmStereoBalanceSlider (int);
void handle_fmStereoPanoramaSlider (int);
void handle_plotTypeSelector (const QString &s);
void handle_cbThemes (int);
void handle_PlotZoomFactor (const QString &s);
void handle_sbDispDelay (int);
void handle_cbTestTone (int v);
void handle_countrySelector (const QString &);
void handle_freqButton ();
void newFrequency (int);
void closeEvent (QCloseEvent *event);
public slots:
void quickStart ();
void setHFplotterView (int);
void hfBufferLoaded ();
void wheelEvent (QWheelEvent *);
void adjustFrequency (int);
void setCRCErrors (int);
void setSyncErrors (int);
void setbitErrorRate (double);
void setGroup (int);
void setPiCode (int);
void setStationLabel (const QString &);
void setRadioText (const QString &);
void setRDSisSynchronized (bool);
void setMusicSpeechFlag (int);
void clearMusicSpeechFlag ();
void scanresult ();
//
// changed or added
void lfBufferLoaded (bool, bool, int);
void iqBufferLoaded ();
void setPTYCode (int, const QString &);
// void clearStationLabel ();
void clearRadioText ();
void setAFDisplay (int, int);
void setSquelchIsActive (bool);
// void showStrength (float, float);
void showPeakLevel (const float, const float);
void showMetaData (const fmProcessor::SMetaData *);
//
// and for the extio handling NOT AVAILABLE IN THIS VERSION
void set_ExtFrequency (int);
void set_ExtLO (int);
void set_lockLO ();
void set_unlockLO ();
void set_stopHW ();
void set_startHW ();
// void set_changeRate (int);
};