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.
atvmodsettings.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 "atvmodsettings.h"
24 
26  m_channelMarker(0)
27 {
29 }
30 
32 {
34  m_rfBandwidth = 1000000;
35  m_rfOppBandwidth = 0;
37  m_nbLines = 625;
38  m_fps = 25;
40  m_uniformLevel = 0.5f;
42  m_videoPlayLoop = false;
43  m_videoPlay = false;
44  m_cameraPlay = false;
45  m_channelMute = false;
46  m_invertedVideo = false;
47  m_rfScalingFactor = 0.891235351562f * SDR_TX_SCALEF; // -1dB
48  m_fmExcursion = 0.5f; // half bandwidth
49  m_forceDecimator = false;
50  m_showOverlayText = false;
51  m_overlayText = "ATV";
52  m_rgbColor = QColor(255, 255, 255).rgb();
53  m_title = "ATV Modulator";
54  m_useReverseAPI = false;
55  m_reverseAPIAddress = "127.0.0.1";
56  m_reverseAPIPort = 8888;
59 }
60 
61 QByteArray ATVModSettings::serialize() const
62 {
63  SimpleSerializer s(1);
64 
67  s.writeS32(3, roundf(m_uniformLevel * 100.0)); // percent
68  s.writeS32(4, (int) m_atvStd);
69  s.writeS32(5, (int) m_atvModInput);
70  s.writeU32(6, m_rgbColor);
72  s.writeS32(8, (int) m_atvModulation);
74  s.writeS32(10, m_nbLines);
75  s.writeS32(11, m_fps);
76  s.writeS32(12, roundf(m_rfScalingFactor / 327.68f));
77  s.writeS32(13, roundf(m_fmExcursion * 1000.0)); // pro mill
79 
80  if (m_channelMarker) {
82  }
83 
84  s.writeString(16, m_title);
90 
91  return s.final();
92 }
93 
94 bool ATVModSettings::deserialize(const QByteArray& data)
95 {
96  SimpleDeserializer d(data);
97 
98  if(!d.isValid())
99  {
100  resetToDefaults();
101  return false;
102  }
103 
104  if(d.getVersion() == 1)
105  {
106  QByteArray bytetmp;
107  qint32 tmp;
108  uint32_t utmp;
109 
110  d.readS32(1, &tmp, 0);
112  d.readReal(2, &m_rfBandwidth, 1000000);
113  d.readS32(3, &tmp, 100);
114  m_uniformLevel = tmp / 100.0; // percent
115  d.readS32(4, &tmp, 0);
116  m_atvStd = (ATVStd) tmp;
117  d.readS32(5, &tmp, 0);
118  m_atvModInput = (ATVModInput) tmp;
119  d.readU32(6, &m_rgbColor, 0);
120  d.readReal(7, &m_rfOppBandwidth, 0);
121  d.readS32(8, &tmp, 0);
123  d.readBool(9, &m_invertedVideo, false);
124  d.readS32(10, &m_nbLines, 625);
125  d.readS32(11, &m_fps, 25);
126  d.readS32(12, &tmp, 80);
127  m_rfScalingFactor = tmp * 327.68f;
128  d.readS32(13, &tmp, 250);
129  m_fmExcursion = tmp / 1000.0; // pro mill
130  d.readString(14, &m_overlayText, "ATV");
131 
132  if (m_channelMarker)
133  {
134  d.readBlob(15, &bytetmp);
135  m_channelMarker->deserialize(bytetmp);
136  }
137 
138  d.readString(16, &m_title, "ATV Modulator");
139  d.readBool(17, &m_useReverseAPI, false);
140  d.readString(18, &m_reverseAPIAddress, "127.0.0.1");
141  d.readU32(19, &utmp, 0);
142 
143  if ((utmp > 1023) && (utmp < 65535)) {
144  m_reverseAPIPort = utmp;
145  } else {
146  m_reverseAPIPort = 8888;
147  }
148 
149  d.readU32(20, &utmp, 0);
150  m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
151  d.readU32(21, &utmp, 0);
152  m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
153  return true;
154  }
155  else
156  {
157  resetToDefaults();
158  return false;
159  }
160 }
float m_rfScalingFactor
Scaling factor from +/-1 to +/-2^15.
ATVModulation m_atvModulation
RF modulation type.
uint16_t m_reverseAPIDeviceIndex
int m_nbLines
Number of lines per full frame.
QByteArray serialize() const
quint32 m_rgbColor
void writeBlob(quint32 id, const QByteArray &value)
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
qint64 m_inputFrequencyOffset
offset from baseband center frequency
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
QString m_overlayText
bool m_channelMute
Mute channel baseband output.
bool m_forceDecimator
Forces decimator even when channel and source sample rates are equal.
#define SDR_TX_SCALEF
Definition: dsptypes.h:39
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
int m_fps
Number of frames per second.
uint16_t m_reverseAPIChannelIndex
QString m_reverseAPIAddress
float m_fmExcursion
FM excursion factor relative to full bandwidth.
void writeS32(quint32 id, qint32 value)
bool m_showOverlayText
Show overlay text on image.
bool m_invertedVideo
True if video signal is inverted before modulation.
quint32 getVersion() const
virtual bool deserialize(const QByteArray &data)=0
ATVStd m_atvStd
Standard.
ATVModInput m_atvModInput
Input source type.
void writeU32(quint32 id, quint32 value)
void writeReal(quint32 id, Real value)
bool m_videoPlay
True to play video and false to pause.
bool readReal(quint32 id, Real *result, Real def=0) const
virtual QByteArray serialize() const =0
bool m_cameraPlay
True to play camera video and false to pause.
Real m_uniformLevel
Percentage between black and white for uniform screen display.
void writeBool(quint32 id, bool value)
Serializable * m_channelMarker
Real m_rfBandwidth
Bandwidth of modulated signal or direct sideband for SSB / vestigial SSB.
void writeString(quint32 id, const QString &value)
uint16_t m_reverseAPIPort
Real m_rfOppBandwidth
Bandwidth of opposite sideband for vestigial SSB.
const QByteArray & final()
bool deserialize(const QByteArray &data)
bool m_videoPlayLoop
Play video in a loop.