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.
freedvdemodsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2019 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 "freedvdemodsettings.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_audioMute = false;
43  m_agc = true;
44  m_volume = 3.0;
45  m_volumeIn = 1.0;
46  m_spanLog2 = 3;
48  m_rgbColor = QColor(0, 255, 204).rgb();
49  m_title = "FreeDV Demodulator";
52  m_useReverseAPI = false;
53  m_reverseAPIAddress = "127.0.0.1";
54  m_reverseAPIPort = 8888;
57 }
58 
60 {
61  SimpleSerializer s(1);
63  s.writeS32(3, m_volume * 10.0);
64 
65  if (m_spectrumGUI) {
67  }
68 
69  s.writeU32(5, m_rgbColor);
70  s.writeS32(6, m_volumeIn * 10.0);
71  s.writeS32(7, m_spanLog2);
72  s.writeBool(11, m_agc);
73  s.writeString(16, m_title);
80  s.writeS32(23, (int) m_freeDVMode);
81 
82  return s.final();
83 }
84 
85 bool FreeDVDemodSettings::deserialize(const QByteArray& data)
86 {
87  SimpleDeserializer d(data);
88 
89  if(!d.isValid())
90  {
92  return false;
93  }
94 
95  if(d.getVersion() == 1)
96  {
97  QByteArray bytetmp;
98  qint32 tmp;
99  uint32_t utmp;
100  QString strtmp;
101 
103  d.readS32(2, &tmp, 30);
104  d.readS32(3, &tmp, 30);
105  m_volume = tmp / 10.0;
106 
107  if (m_spectrumGUI) {
108  d.readBlob(4, &bytetmp);
109  m_spectrumGUI->deserialize(bytetmp);
110  }
111 
112  d.readU32(5, &m_rgbColor);
113  d.readS32(6, &tmp, 10);
114  m_volumeIn = tmp / 10.0;
115  d.readS32(7, &m_spanLog2, 3);
116  d.readBool(11, &m_agc, false);
117  d.readString(16, &m_title, "SSB Demodulator");
119  d.readBool(18, &m_useReverseAPI, false);
120  d.readString(19, &m_reverseAPIAddress, "127.0.0.1");
121  d.readU32(20, &utmp, 0);
122 
123  if ((utmp > 1023) && (utmp < 65535)) {
124  m_reverseAPIPort = utmp;
125  } else {
126  m_reverseAPIPort = 8888;
127  }
128 
129  d.readU32(21, &utmp, 0);
130  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
131  d.readU32(22, &utmp, 0);
132  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
133 
134  d.readS32(23, &tmp, 0);
135  if ((tmp < 0) || (tmp > (int) FreeDVMode::FreeDVMode700D)) {
136  m_freeDVMode = FreeDVMode::FreeDVMode2400A;
137  } else {
138  m_freeDVMode = (FreeDVMode) tmp;
139  }
140 
141  return true;
142  }
143  else
144  {
145  resetToDefaults();
146  return false;
147  }
148 }
149 
151 {
152  switch(freeDVMode)
153  {
154  case FreeDVMode800XA: // C4FM NB
155  case FreeDVMode700C: // OFDM
156  case FreeDVMode700D: // OFDM
157  case FreeDVMode1600: // OFDM
158  return 2400.0;
159  break;
160  case FreeDVMode2400A: // C4FM WB
161  default:
162  return 6000.0;
163  break;
164  }
165 }
166 
168 {
169  switch(freeDVMode)
170  {
171  case FreeDVMode800XA: // C4FM NB
172  return 400.0;
173  break;
174  case FreeDVMode700C: // OFDM
175  case FreeDVMode700D: // OFDM
176  case FreeDVMode1600: // OFDM
177  return 600.0;
178  break;
179  case FreeDVMode2400A: // C4FM WB
180  default:
181  return 0.0;
182  break;
183  }
184 }
185 
187 {
188  if (freeDVMode == FreeDVMode2400A) {
189  return 48000;
190  } else {
191  return 8000;
192  }
193 }
static const QString m_defaultDeviceName
Serializable * m_spectrumGUI
static const int m_minPowerThresholdDB
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
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
bool deserialize(const QByteArray &data)
static const float m_mminPowerThresholdDBf
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)
QByteArray serialize() const
static int getHiCutoff(FreeDVMode freeDVMode)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
static int getLowCutoff(FreeDVMode freeDVMode)
static int getModSampleRate(FreeDVMode freeDVMode)