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.
ssbmodsettings.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 "ssbmodsettings.h"
24 
26  1,
27  2,
28  5,
29  10,
30  20,
31  50,
32  100,
33  200,
34  500,
35  990};
36 
38 
40  m_channelMarker(0),
41  m_spectrumGUI(0),
42  m_cwKeyerGUI(0)
43 {
45 }
46 
48 {
50  m_bandwidth = 3000.0;
51  m_lowCutoff = 300.0;
52  m_usb = true;
53  m_toneFrequency = 1000.0;
54  m_volumeFactor = 1.0;
55  m_spanLog2 = 3;
56  m_audioBinaural = false;
57  m_audioFlipChannels = false;
58  m_dsb = false;
59  m_audioMute = false;
60  m_playLoop = false;
61  m_agc = false;
62  m_rgbColor = QColor(0, 255, 0).rgb();
63  m_title = "SSB Modulator";
64  m_modAFInput = SSBModInputAF::SSBModInputNone;
68  m_feedbackAudioEnable = false;
69  m_useReverseAPI = false;
70  m_reverseAPIAddress = "127.0.0.1";
71  m_reverseAPIPort = 8888;
74 }
75 
76 QByteArray SSBModSettings::serialize() const
77 {
78  SimpleSerializer s(1);
79 
81  s.writeS32(2, roundf(m_bandwidth / 100.0));
82  s.writeS32(3, roundf(m_toneFrequency / 10.0));
83 
84  if (m_spectrumGUI) {
86  }
87 
88  s.writeU32(5, m_rgbColor);
89 
90  if (m_cwKeyerGUI) {
92  }
93 
94  s.writeS32(7, roundf(m_lowCutoff / 100.0));
95  s.writeS32(8, m_spanLog2);
98  s.writeBool(11, m_dsb);
99  s.writeBool(12, m_agc);
100 
101  if (m_channelMarker) {
103  }
104 
105  s.writeString(19, m_title);
107  s.writeS32(21, (int) m_modAFInput);
108  s.writeBool(22, m_useReverseAPI);
110  s.writeU32(24, m_reverseAPIPort);
116 
117  return s.final();
118 }
119 
120 bool SSBModSettings::deserialize(const QByteArray& data)
121 {
122  SimpleDeserializer d(data);
123 
124  if(!d.isValid())
125  {
126  resetToDefaults();
127  return false;
128  }
129 
130  if(d.getVersion() == 1)
131  {
132  QByteArray bytetmp;
133  qint32 tmp;
134  uint32_t utmp;
135 
136  d.readS32(1, &tmp, 0);
138 
139  d.readS32(2, &tmp, 30);
140  m_bandwidth = tmp * 100.0;
141 
142  d.readS32(3, &tmp, 100);
143  m_toneFrequency = tmp * 10.0;
144 
145  if (m_spectrumGUI)
146  {
147  d.readBlob(4, &bytetmp);
148  m_spectrumGUI->deserialize(bytetmp);
149  }
150 
151  d.readU32(5, &m_rgbColor);
152 
153  if (m_cwKeyerGUI) {
154  d.readBlob(6, &bytetmp);
155  m_cwKeyerGUI->deserialize(bytetmp);
156  }
157 
158  d.readS32(7, &tmp, 3);
159  m_lowCutoff = tmp * 100.0;
160 
161  d.readS32(8, &m_spanLog2, 3);
162  d.readBool(9, &m_audioBinaural, false);
163  d.readBool(10, &m_audioFlipChannels, false);
164  d.readBool(11, &m_dsb, false);
165  d.readBool(12, &m_agc, false);
166  d.readS32(13, &tmp, 7);
167 
168  if (m_channelMarker) {
169  d.readBlob(18, &bytetmp);
170  m_channelMarker->deserialize(bytetmp);
171  }
172 
173  d.readString(19, &m_title, "SSB Modulator");
175 
176  d.readS32(21, &tmp, 0);
177  if ((tmp < 0) || (tmp > (int) SSBModInputAF::SSBModInputTone)) {
179  } else {
180  m_modAFInput = (SSBModInputAF) tmp;
181  }
182 
183  d.readBool(22, &m_useReverseAPI, false);
184  d.readString(23, &m_reverseAPIAddress, "127.0.0.1");
185  d.readU32(24, &utmp, 0);
186 
187  if ((utmp > 1023) && (utmp < 65535)) {
188  m_reverseAPIPort = utmp;
189  } else {
190  m_reverseAPIPort = 8888;
191  }
192 
193  d.readU32(25, &utmp, 0);
194  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
195  d.readU32(26, &utmp, 0);
196  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
198  d.readReal(28, &m_feedbackVolumeFactor, 1.0);
199  d.readBool(29, &m_feedbackAudioEnable, false);
200 
201  return true;
202  }
203  else
204  {
205  resetToDefaults();
206  return false;
207  }
208 }
static const QString m_defaultDeviceName
static const int m_agcTimeConstant[]
qint64 m_inputFrequencyOffset
uint16_t m_reverseAPIChannelIndex
QString m_feedbackAudioDeviceName
This is the audio device you send the audio samples to for audio feedback.
void writeBlob(quint32 id, const QByteArray &value)
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
float m_feedbackVolumeFactor
Serializable * m_channelMarker
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
QString m_audioDeviceName
This is the audio device you get the audio samples from.
SSBModInputAF m_modAFInput
uint16_t m_reverseAPIDeviceIndex
bool m_audioFlipChannels
void writeS32(quint32 id, qint32 value)
QByteArray serialize() const
quint32 getVersion() const
Serializable * m_spectrumGUI
virtual bool deserialize(const QByteArray &data)=0
uint16_t m_reverseAPIPort
void writeU32(quint32 id, quint32 value)
void writeReal(quint32 id, Real value)
Serializable * m_cwKeyerGUI
bool readReal(quint32 id, Real *result, Real def=0) const
virtual QByteArray serialize() const =0
void writeBool(quint32 id, bool value)
static const int m_nbAGCTimeConstants
QString m_reverseAPIAddress
bool deserialize(const QByteArray &data)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
quint32 m_rgbColor
bool m_feedbackAudioEnable