2017-10-02 17:01:13 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB. //
|
|
|
|
// //
|
|
|
|
// This program is free som_udpCopyAudioftware; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2017-10-02 17:01:13 -04:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "settings/serializable.h"
|
|
|
|
#include "dsddemodsettings.h"
|
|
|
|
|
|
|
|
DSDDemodSettings::DSDDemodSettings() :
|
|
|
|
m_channelMarker(0),
|
|
|
|
m_scopeGUI(0)
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodSettings::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_inputFrequencyOffset = 0;
|
2017-10-03 18:29:47 -04:00
|
|
|
m_rfBandwidth = 12500.0;
|
2018-04-01 03:33:08 -04:00
|
|
|
m_fmDeviation = 3500.0;
|
|
|
|
m_demodGain = 1.0;
|
2017-10-03 18:29:47 -04:00
|
|
|
m_volume = 2.0;
|
2017-10-02 17:01:13 -04:00
|
|
|
m_baudRate = 4800;
|
|
|
|
m_squelchGate = 5; // 10s of ms at 48000 Hz sample rate. Corresponds to 2400 for AGC attack
|
2017-10-03 18:29:47 -04:00
|
|
|
m_squelch = -40.0;
|
2017-10-02 17:01:13 -04:00
|
|
|
m_audioMute = false;
|
|
|
|
m_enableCosineFiltering = false;
|
|
|
|
m_syncOrConstellation = false;
|
|
|
|
m_slot1On = true;
|
|
|
|
m_slot2On = false;
|
|
|
|
m_tdmaStereo = false;
|
|
|
|
m_pllLock = true;
|
|
|
|
m_rgbColor = QColor(0, 255, 255).rgb();
|
2017-11-19 05:36:20 -05:00
|
|
|
m_title = "DSD Demodulator";
|
2017-12-26 04:59:51 -05:00
|
|
|
m_highPassFilter = false;
|
2018-03-12 20:39:43 -04:00
|
|
|
m_traceLengthMutliplier = 6; // 300 ms
|
|
|
|
m_traceStroke = 100;
|
|
|
|
m_traceDecay = 200;
|
2018-03-28 02:00:27 -04:00
|
|
|
m_audioDeviceName = AudioDeviceManager::m_defaultDeviceName;
|
2019-09-22 19:25:17 -04:00
|
|
|
m_streamIndex = 0;
|
2018-12-22 07:05:48 -05:00
|
|
|
m_useReverseAPI = false;
|
|
|
|
m_reverseAPIAddress = "127.0.0.1";
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
m_reverseAPIDeviceIndex = 0;
|
|
|
|
m_reverseAPIChannelIndex = 0;
|
2017-10-02 17:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray DSDDemodSettings::serialize() const
|
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
2017-10-03 16:24:07 -04:00
|
|
|
s.writeS32(1, m_inputFrequencyOffset);
|
2017-10-02 17:01:13 -04:00
|
|
|
s.writeS32(2, m_rfBandwidth/100.0);
|
|
|
|
s.writeS32(3, m_demodGain*100.0);
|
|
|
|
s.writeS32(4, m_fmDeviation/100.0);
|
2018-10-22 08:51:47 -04:00
|
|
|
s.writeS32(5, m_squelch);
|
2019-04-24 11:50:31 -04:00
|
|
|
s.writeBool(6, m_pllLock);
|
2017-10-02 17:01:13 -04:00
|
|
|
s.writeU32(7, m_rgbColor);
|
|
|
|
s.writeS32(8, m_squelchGate);
|
|
|
|
s.writeS32(9, m_volume*10.0);
|
|
|
|
|
|
|
|
if (m_scopeGUI) {
|
|
|
|
s.writeBlob(10, m_scopeGUI->serialize());
|
|
|
|
}
|
|
|
|
|
|
|
|
s.writeS32(11, m_baudRate);
|
|
|
|
s.writeBool(12, m_enableCosineFiltering);
|
|
|
|
s.writeBool(13, m_syncOrConstellation);
|
|
|
|
s.writeBool(14, m_slot1On);
|
|
|
|
s.writeBool(15, m_slot2On);
|
|
|
|
s.writeBool(16, m_tdmaStereo);
|
|
|
|
|
|
|
|
if (m_channelMarker) {
|
|
|
|
s.writeBlob(17, m_channelMarker->serialize());
|
|
|
|
}
|
|
|
|
|
2017-11-19 05:36:20 -05:00
|
|
|
s.writeString(18, m_title);
|
2017-12-26 04:59:51 -05:00
|
|
|
s.writeBool(19, m_highPassFilter);
|
2018-03-28 02:00:27 -04:00
|
|
|
s.writeString(20, m_audioDeviceName);
|
2018-03-12 15:39:16 -04:00
|
|
|
s.writeS32(21, m_traceLengthMutliplier);
|
2018-03-12 20:39:43 -04:00
|
|
|
s.writeS32(22, m_traceStroke);
|
|
|
|
s.writeS32(23, m_traceDecay);
|
2018-12-22 07:05:48 -05:00
|
|
|
s.writeBool(24, m_useReverseAPI);
|
|
|
|
s.writeString(25, m_reverseAPIAddress);
|
|
|
|
s.writeU32(26, m_reverseAPIPort);
|
|
|
|
s.writeU32(27, m_reverseAPIDeviceIndex);
|
|
|
|
s.writeU32(28, m_reverseAPIChannelIndex);
|
2019-04-24 11:50:31 -04:00
|
|
|
s.writeBool(29, m_audioMute);
|
2019-09-22 19:25:17 -04:00
|
|
|
s.writeS32(30, m_streamIndex);
|
2017-11-19 05:36:20 -05:00
|
|
|
|
2017-10-02 17:01:13 -04:00
|
|
|
return s.final();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DSDDemodSettings::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
|
|
|
if (!d.isValid())
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d.getVersion() == 1)
|
|
|
|
{
|
|
|
|
QByteArray bytetmp;
|
|
|
|
QString strtmp;
|
|
|
|
qint32 tmp;
|
2018-12-22 07:05:48 -05:00
|
|
|
uint32_t utmp;
|
2017-10-02 17:01:13 -04:00
|
|
|
|
|
|
|
if (m_channelMarker) {
|
|
|
|
d.readBlob(17, &bytetmp);
|
|
|
|
m_channelMarker->deserialize(bytetmp);
|
|
|
|
}
|
|
|
|
|
2017-10-03 16:24:07 -04:00
|
|
|
d.readS32(1, &tmp, 0);
|
|
|
|
m_inputFrequencyOffset = tmp;
|
2017-10-03 18:29:47 -04:00
|
|
|
d.readS32(2, &tmp, 125);
|
2017-10-02 17:01:13 -04:00
|
|
|
m_rfBandwidth = tmp * 100.0;
|
2017-10-03 18:29:47 -04:00
|
|
|
d.readS32(3, &tmp, 125);
|
2017-10-02 17:01:13 -04:00
|
|
|
m_demodGain = tmp / 100.0;
|
2017-10-03 18:29:47 -04:00
|
|
|
d.readS32(4, &tmp, 50);
|
2017-10-02 17:01:13 -04:00
|
|
|
m_fmDeviation = tmp * 100.0;
|
2018-10-22 08:51:47 -04:00
|
|
|
d.readS32(5, &tmp, -40);
|
|
|
|
m_squelch = tmp < -100 ? tmp / 10.0 : tmp;
|
2019-04-24 11:50:31 -04:00
|
|
|
d.readBool(6, &m_pllLock, true);
|
2017-10-02 17:01:13 -04:00
|
|
|
d.readU32(7, &m_rgbColor);
|
|
|
|
d.readS32(8, &m_squelchGate, 5);
|
|
|
|
d.readS32(9, &tmp, 20);
|
|
|
|
m_volume = tmp / 10.0;
|
|
|
|
|
|
|
|
if (m_scopeGUI) {
|
|
|
|
d.readBlob(10, &bytetmp);
|
|
|
|
m_scopeGUI->deserialize(bytetmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readS32(11, &m_baudRate, 4800);
|
|
|
|
d.readBool(12, &m_enableCosineFiltering, false);
|
|
|
|
d.readBool(13, &m_syncOrConstellation, false);
|
|
|
|
d.readBool(14, &m_slot1On, false);
|
|
|
|
d.readBool(15, &m_slot2On, false);
|
|
|
|
d.readBool(16, &m_tdmaStereo, false);
|
2017-11-19 05:36:20 -05:00
|
|
|
d.readString(18, &m_title, "DSD Demodulator");
|
2017-12-26 04:59:51 -05:00
|
|
|
d.readBool(19, &m_highPassFilter, false);
|
2018-03-28 02:00:27 -04:00
|
|
|
d.readString(20, &m_audioDeviceName, AudioDeviceManager::m_defaultDeviceName);
|
2018-03-13 03:16:39 -04:00
|
|
|
d.readS32(21, &tmp, 6);
|
2018-03-12 20:39:43 -04:00
|
|
|
m_traceLengthMutliplier = tmp < 2 ? 2 : tmp > 30 ? 30 : tmp;
|
|
|
|
d.readS32(22, &tmp, 100);
|
|
|
|
m_traceStroke = tmp < 0 ? 0 : tmp > 255 ? 255 : tmp;
|
|
|
|
d.readS32(23, &tmp, 200);
|
|
|
|
m_traceDecay = tmp < 0 ? 0 : tmp > 255 ? 255 : tmp;
|
2018-12-22 07:05:48 -05:00
|
|
|
d.readBool(24, &m_useReverseAPI, false);
|
|
|
|
d.readString(25, &m_reverseAPIAddress, "127.0.0.1");
|
|
|
|
d.readU32(26, &utmp, 0);
|
|
|
|
|
|
|
|
if ((utmp > 1023) && (utmp < 65535)) {
|
|
|
|
m_reverseAPIPort = utmp;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIPort = 8888;
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readU32(27, &utmp, 0);
|
|
|
|
m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
|
|
|
|
d.readU32(28, &utmp, 0);
|
|
|
|
m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
|
2019-04-24 11:50:31 -04:00
|
|
|
d.readBool(29, &m_audioMute, false);
|
2019-09-22 19:25:17 -04:00
|
|
|
d.readS32(30, &m_streamIndex, 0);
|
2017-10-02 17:01:13 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|