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.
dsddemodsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB. //
3 // //
4 // This program is free som_udpCopyAudioftware; 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 "dsddemodsettings.h"
24 
26  m_channelMarker(0),
27  m_scopeGUI(0)
28 {
30 }
31 
33 {
35  m_rfBandwidth = 12500.0;
36  m_fmDeviation = 3500.0;
37  m_demodGain = 1.0;
38  m_volume = 2.0;
39  m_baudRate = 4800;
40  m_squelchGate = 5; // 10s of ms at 48000 Hz sample rate. Corresponds to 2400 for AGC attack
41  m_squelch = -40.0;
42  m_audioMute = false;
44  m_syncOrConstellation = false;
45  m_slot1On = true;
46  m_slot2On = false;
47  m_tdmaStereo = false;
48  m_pllLock = true;
49  m_rgbColor = QColor(0, 255, 255).rgb();
50  m_title = "DSD Demodulator";
51  m_highPassFilter = false;
52  m_traceLengthMutliplier = 6; // 300 ms
53  m_traceStroke = 100;
54  m_traceDecay = 200;
56  m_useReverseAPI = false;
57  m_reverseAPIAddress = "127.0.0.1";
58  m_reverseAPIPort = 8888;
61 }
62 
63 QByteArray DSDDemodSettings::serialize() const
64 {
65  SimpleSerializer s(1);
67  s.writeS32(2, m_rfBandwidth/100.0);
68  s.writeS32(3, m_demodGain*100.0);
69  s.writeS32(4, m_fmDeviation/100.0);
70  s.writeS32(5, m_squelch);
71  s.writeBool(6, m_pllLock);
72  s.writeU32(7, m_rgbColor);
73  s.writeS32(8, m_squelchGate);
74  s.writeS32(9, m_volume*10.0);
75 
76  if (m_scopeGUI) {
77  s.writeBlob(10, m_scopeGUI->serialize());
78  }
79 
80  s.writeS32(11, m_baudRate);
83  s.writeBool(14, m_slot1On);
84  s.writeBool(15, m_slot2On);
85  s.writeBool(16, m_tdmaStereo);
86 
87  if (m_channelMarker) {
89  }
90 
91  s.writeString(18, m_title);
95  s.writeS32(22, m_traceStroke);
96  s.writeS32(23, m_traceDecay);
102  s.writeBool(29, m_audioMute);
103 
104  return s.final();
105 }
106 
107 bool DSDDemodSettings::deserialize(const QByteArray& data)
108 {
109  SimpleDeserializer d(data);
110 
111  if (!d.isValid())
112  {
113  resetToDefaults();
114  return false;
115  }
116 
117  if (d.getVersion() == 1)
118  {
119  QByteArray bytetmp;
120  QString strtmp;
121  qint32 tmp;
122  uint32_t utmp;
123 
124  if (m_channelMarker) {
125  d.readBlob(17, &bytetmp);
126  m_channelMarker->deserialize(bytetmp);
127  }
128 
129  d.readS32(1, &tmp, 0);
131  d.readS32(2, &tmp, 125);
132  m_rfBandwidth = tmp * 100.0;
133  d.readS32(3, &tmp, 125);
134  m_demodGain = tmp / 100.0;
135  d.readS32(4, &tmp, 50);
136  m_fmDeviation = tmp * 100.0;
137  d.readS32(5, &tmp, -40);
138  m_squelch = tmp < -100 ? tmp / 10.0 : tmp;
139  d.readBool(6, &m_pllLock, true);
140  d.readU32(7, &m_rgbColor);
141  d.readS32(8, &m_squelchGate, 5);
142  d.readS32(9, &tmp, 20);
143  m_volume = tmp / 10.0;
144 
145  if (m_scopeGUI) {
146  d.readBlob(10, &bytetmp);
147  m_scopeGUI->deserialize(bytetmp);
148  }
149 
150  d.readS32(11, &m_baudRate, 4800);
151  d.readBool(12, &m_enableCosineFiltering, false);
152  d.readBool(13, &m_syncOrConstellation, false);
153  d.readBool(14, &m_slot1On, false);
154  d.readBool(15, &m_slot2On, false);
155  d.readBool(16, &m_tdmaStereo, false);
156  d.readString(18, &m_title, "DSD Demodulator");
157  d.readBool(19, &m_highPassFilter, false);
159  d.readS32(21, &tmp, 6);
160  m_traceLengthMutliplier = tmp < 2 ? 2 : tmp > 30 ? 30 : tmp;
161  d.readS32(22, &tmp, 100);
162  m_traceStroke = tmp < 0 ? 0 : tmp > 255 ? 255 : tmp;
163  d.readS32(23, &tmp, 200);
164  m_traceDecay = tmp < 0 ? 0 : tmp > 255 ? 255 : tmp;
165  d.readBool(24, &m_useReverseAPI, false);
166  d.readString(25, &m_reverseAPIAddress, "127.0.0.1");
167  d.readU32(26, &utmp, 0);
168 
169  if ((utmp > 1023) && (utmp < 65535)) {
170  m_reverseAPIPort = utmp;
171  } else {
172  m_reverseAPIPort = 8888;
173  }
174 
175  d.readU32(27, &utmp, 0);
176  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
177  d.readU32(28, &utmp, 0);
178  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
179  d.readBool(29, &m_audioMute, false);
180 
181  return true;
182  }
183  else
184  {
185  resetToDefaults();
186  return false;
187  }
188 }
189 
static const QString m_defaultDeviceName
QByteArray serialize() const
void writeBlob(quint32 id, const QByteArray &value)
Serializable * m_channelMarker
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
qint64 m_inputFrequencyOffset
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
uint16_t m_reverseAPIDeviceIndex
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
uint16_t m_reverseAPIPort
bool deserialize(const QByteArray &data)
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
virtual bool deserialize(const QByteArray &data)=0
void writeU32(quint32 id, quint32 value)
virtual QByteArray serialize() const =0
void writeBool(quint32 id, bool value)
uint16_t m_reverseAPIChannelIndex
void writeString(quint32 id, const QString &value)
QString m_reverseAPIAddress
const QByteArray & final()
Serializable * m_scopeGUI