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.
ammodsettings.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 "ammodsettings.h"
24 
26  m_channelMarker(0),
27  m_cwKeyerGUI(0)
28 {
30 }
31 
33 {
35  m_rfBandwidth = 12500.0;
36  m_modFactor = 0.2f;
37  m_toneFrequency = 1000.0f;
38  m_volumeFactor = 1.0f;
39  m_channelMute = false;
40  m_playLoop = false;
41  m_rgbColor = QColor(255, 255, 0).rgb();
42  m_title = "AM Modulator";
43  m_modAFInput = AMModInputAF::AMModInputNone;
47  m_feedbackAudioEnable = false;
48  m_useReverseAPI = false;
49  m_reverseAPIAddress = "127.0.0.1";
50  m_reverseAPIPort = 8888;
53 }
54 
55 QByteArray AMModSettings::serialize() const
56 {
57  SimpleSerializer s(1);
58 
62  s.writeReal(4, m_modFactor);
63  s.writeU32(5, m_rgbColor);
65 
66  if (m_cwKeyerGUI) {
68  }
69 
70  if (m_channelMarker) {
72  }
73 
74  s.writeString(9, m_title);
76  s.writeS32(11, (int) m_modAFInput);
85 
86  return s.final();
87 }
88 
89 bool AMModSettings::deserialize(const QByteArray& data)
90 {
91  SimpleDeserializer d(data);
92 
93  if(!d.isValid())
94  {
96  return false;
97  }
98 
99  if(d.getVersion() == 1)
100  {
101  QByteArray bytetmp;
102  qint32 tmp;
103  uint32_t utmp;
104 
105  d.readS32(1, &tmp, 0);
107  d.readReal(2, &m_rfBandwidth, 12500.0);
108  d.readReal(3, &m_toneFrequency, 1000.0);
109  d.readReal(4, &m_modFactor, 0.2f);
110  d.readU32(5, &m_rgbColor);
111  d.readReal(6, &m_volumeFactor, 1.0);
112 
113  if (m_cwKeyerGUI) {
114  d.readBlob(7, &bytetmp);
115  m_cwKeyerGUI->deserialize(bytetmp);
116  }
117 
118  if (m_channelMarker) {
119  d.readBlob(8, &bytetmp);
120  m_channelMarker->deserialize(bytetmp);
121  }
122 
123  d.readString(9, &m_title, "AM Modulator");
125 
126  d.readS32(11, &tmp, 0);
127  if ((tmp < 0) || (tmp > (int) AMModInputAF::AMModInputTone)) {
129  } else {
130  m_modAFInput = (AMModInputAF) tmp;
131  }
132 
133  d.readBool(12, &m_useReverseAPI, false);
134  d.readString(13, &m_reverseAPIAddress, "127.0.0.1");
135  d.readU32(14, &utmp, 0);
136 
137  if ((utmp > 1023) && (utmp < 65535)) {
138  m_reverseAPIPort = utmp;
139  } else {
140  m_reverseAPIPort = 8888;
141  }
142 
143  d.readU32(15, &utmp, 0);
144  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
145  d.readU32(16, &utmp, 0);
146  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
148  d.readReal(18, &m_feedbackVolumeFactor, 1.0);
149  d.readBool(19, &m_feedbackAudioEnable, false);
150 
151  return true;
152  }
153  else
154  {
155  resetToDefaults();
156  return false;
157  }
158 }
static const QString m_defaultDeviceName
float m_feedbackVolumeFactor
Definition: ammodsettings.h:48
bool m_feedbackAudioEnable
Definition: ammodsettings.h:49
uint16_t m_reverseAPIDeviceIndex
Definition: ammodsettings.h:53
QByteArray serialize() const
void writeBlob(quint32 id, const QByteArray &value)
QString m_reverseAPIAddress
Definition: ammodsettings.h:51
Serializable * m_cwKeyerGUI
Definition: ammodsettings.h:57
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
Serializable * m_channelMarker
Definition: ammodsettings.h:56
bool readBool(quint32 id, bool *result, bool def=false) const
bool isValid() const
unsigned int uint32_t
Definition: rtptypes_win.h:46
float m_volumeFactor
Definition: ammodsettings.h:40
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
bool deserialize(const QByteArray &data)
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
void resetToDefaults()
quint32 m_rgbColor
Definition: ammodsettings.h:43
void writeS32(quint32 id, qint32 value)
QString m_feedbackAudioDeviceName
This is the audio device you send the audio samples to for audio feedback.
Definition: ammodsettings.h:47
quint32 getVersion() const
virtual bool deserialize(const QByteArray &data)=0
uint16_t m_reverseAPIChannelIndex
Definition: ammodsettings.h:54
void writeU32(quint32 id, quint32 value)
QString m_title
Definition: ammodsettings.h:44
qint64 m_inputFrequencyOffset
Definition: ammodsettings.h:36
void writeReal(quint32 id, Real value)
QString m_audioDeviceName
This is the audio device you get the audio samples from.
Definition: ammodsettings.h:46
bool readReal(quint32 id, Real *result, Real def=0) const
virtual QByteArray serialize() const =0
void writeBool(quint32 id, bool value)
bool m_useReverseAPI
Definition: ammodsettings.h:50
float m_toneFrequency
Definition: ammodsettings.h:39
void writeString(quint32 id, const QString &value)
AMModInputAF m_modAFInput
Definition: ammodsettings.h:45
const QByteArray & final()
uint16_t m_reverseAPIPort
Definition: ammodsettings.h:52