SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
ssbdemodsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB. //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include <QColor>
19 
20 #include "dsp/dspengine.h"
21 #include "util/simpleserializer.h"
22 #include "settings/serializable.h"
23 #include "ssbdemodsettings.h"
24 
25 #ifdef SDR_RX_SAMPLE_24BIT
28 #else
31 #endif
32 
34  m_channelMarker(0),
35  m_spectrumGUI(0)
36 {
38 }
39 
41 {
42  m_audioBinaural = false;
43  m_audioFlipChannels = false;
44  m_dsb = false;
45  m_audioMute = false;
46  m_agc = false;
47  m_agcClamping = false;
48  m_agcPowerThreshold = -100;
50  m_agcTimeLog2 = 7;
51  m_rfBandwidth = 3000;
52  m_lowCutoff = 300;
53  m_volume = 1.0;
54  m_spanLog2 = 3;
56  m_rgbColor = QColor(0, 255, 0).rgb();
57  m_title = "SSB Demodulator";
59  m_useReverseAPI = false;
60  m_reverseAPIAddress = "127.0.0.1";
61  m_reverseAPIPort = 8888;
64 }
65 
66 QByteArray SSBDemodSettings::serialize() const
67 {
68  SimpleSerializer s(1);
70  s.writeS32(2, m_rfBandwidth / 100.0);
71  s.writeS32(3, m_volume * 10.0);
72 
73  if (m_spectrumGUI) {
75  }
76 
77  s.writeU32(5, m_rgbColor);
78  s.writeS32(6, m_lowCutoff / 100.0);
79  s.writeS32(7, m_spanLog2);
82  s.writeBool(10, m_dsb);
83  s.writeBool(11, m_agc);
84  s.writeS32(12, m_agcTimeLog2);
87  s.writeBool(15, m_agcClamping);
88  s.writeString(16, m_title);
95 
96  return s.final();
97 }
98 
99 bool SSBDemodSettings::deserialize(const QByteArray& data)
100 {
101  SimpleDeserializer d(data);
102 
103  if(!d.isValid())
104  {
105  resetToDefaults();
106  return false;
107  }
108 
109  if(d.getVersion() == 1)
110  {
111  QByteArray bytetmp;
112  qint32 tmp;
113  uint32_t utmp;
114  QString strtmp;
115 
117  d.readS32(2, &tmp, 30);
118  m_rfBandwidth = tmp * 100.0;
119  d.readS32(3, &tmp, 30);
120  m_volume = tmp / 10.0;
121 
122  if (m_spectrumGUI) {
123  d.readBlob(4, &bytetmp);
124  m_spectrumGUI->deserialize(bytetmp);
125  }
126 
127  d.readU32(5, &m_rgbColor);
128  d.readS32(6, &tmp, 30);
129  m_lowCutoff = tmp * 100.0;
130  d.readS32(7, &m_spanLog2, 3);
131  d.readBool(8, &m_audioBinaural, false);
132  d.readBool(9, &m_audioFlipChannels, false);
133  d.readBool(10, &m_dsb, false);
134  d.readBool(11, &m_agc, false);
135  d.readS32(12, &m_agcTimeLog2, 7);
136  d.readS32(13, &m_agcPowerThreshold, -40);
137  d.readS32(14, &m_agcThresholdGate, 4);
138  d.readBool(15, &m_agcClamping, false);
139  d.readString(16, &m_title, "SSB Demodulator");
141  d.readBool(18, &m_useReverseAPI, false);
142  d.readString(19, &m_reverseAPIAddress, "127.0.0.1");
143  d.readU32(20, &utmp, 0);
144 
145  if ((utmp > 1023) && (utmp < 65535)) {
146  m_reverseAPIPort = utmp;
147  } else {
148  m_reverseAPIPort = 8888;
149  }
150 
151  d.readU32(21, &utmp, 0);
152  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
153  d.readU32(22, &utmp, 0);
154  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
155 
156  return true;
157  }
158  else
159  {
160  resetToDefaults();
161  return false;
162  }
163 }
static const QString m_defaultDeviceName
uint16_t m_reverseAPIPort
void writeBlob(quint32 id, const QByteArray &value)
static const int m_minPowerThresholdDB
QByteArray serialize() const
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool readBool(quint32 id, bool *result, bool def=false) const
bool isValid() const
unsigned int uint32_t
Definition: rtptypes_win.h:46
bool deserialize(const QByteArray &data)
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
Serializable * m_spectrumGUI
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
virtual bool deserialize(const QByteArray &data)=0
uint16_t m_reverseAPIDeviceIndex
void writeU32(quint32 id, quint32 value)
uint16_t m_reverseAPIChannelIndex
qint32 m_inputFrequencyOffset
virtual QByteArray serialize() const =0
void writeBool(quint32 id, bool value)
QString m_reverseAPIAddress
static const float m_mminPowerThresholdDBf
void writeString(quint32 id, const QString &value)
const QByteArray & final()