From a03d08248b0b074d99ca166cabc033a2d93dab6b Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 2 Oct 2017 23:01:13 +0200 Subject: [PATCH] DSD demod: settings --- plugins/channelrx/demoddsd/CMakeLists.txt | 2 + plugins/channelrx/demoddsd/demoddsd.pro | 6 +- plugins/channelrx/demoddsd/dsddemodplugin.cpp | 2 +- .../channelrx/demoddsd/dsddemodsettings.cpp | 141 ++++++++++++++++++ ...{demoddsdsettings.h => dsddemodsettings.h} | 15 +- 5 files changed, 156 insertions(+), 10 deletions(-) create mode 100644 plugins/channelrx/demoddsd/dsddemodsettings.cpp rename plugins/channelrx/demoddsd/{demoddsdsettings.h => dsddemodsettings.h} (87%) diff --git a/plugins/channelrx/demoddsd/CMakeLists.txt b/plugins/channelrx/demoddsd/CMakeLists.txt index 6547bdef5..02a1b533a 100644 --- a/plugins/channelrx/demoddsd/CMakeLists.txt +++ b/plugins/channelrx/demoddsd/CMakeLists.txt @@ -5,6 +5,7 @@ set(dsddemod_SOURCES dsddemodgui.cpp dsddemodplugin.cpp dsddemodbaudrates.cpp + dsddemodsettings.cpp dsddecoder.cpp ) @@ -13,6 +14,7 @@ set(dsddemod_HEADERS dsddemodgui.h dsddemodplugin.h dsddemodbaudrates.h + dsddemodsettings.h dsddecoder.h ) diff --git a/plugins/channelrx/demoddsd/demoddsd.pro b/plugins/channelrx/demoddsd/demoddsd.pro index 6f7f0f900..1779fcd1c 100644 --- a/plugins/channelrx/demoddsd/demoddsd.pro +++ b/plugins/channelrx/demoddsd/demoddsd.pro @@ -41,13 +41,15 @@ SOURCES = dsddecoder.cpp\ dsddemod.cpp\ dsddemodgui.cpp\ dsddemodplugin.cpp\ -dsddemodbaudrates.cpp +dsddemodbaudrates.cpp\ +dsddemodsettings.cpp HEADERS = dsddecoder.h\ dsddemod.h\ dsddemodgui.h\ dsddemodplugin.h\ -dsddemodbaudrates.h +dsddemodbaudrates.h\ +dsddemodsettings.h FORMS = dsddemodgui.ui diff --git a/plugins/channelrx/demoddsd/dsddemodplugin.cpp b/plugins/channelrx/demoddsd/dsddemodplugin.cpp index f6a84a23f..2c1de0032 100644 --- a/plugins/channelrx/demoddsd/dsddemodplugin.cpp +++ b/plugins/channelrx/demoddsd/dsddemodplugin.cpp @@ -24,7 +24,7 @@ const PluginDescriptor DSDDemodPlugin::m_pluginDescriptor = { QString("DSD Demodulator"), - QString("3.6.1"), + QString("3.7.3"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/channelrx/demoddsd/dsddemodsettings.cpp b/plugins/channelrx/demoddsd/dsddemodsettings.cpp new file mode 100644 index 000000000..a927d419f --- /dev/null +++ b/plugins/channelrx/demoddsd/dsddemodsettings.cpp @@ -0,0 +1,141 @@ +/////////////////////////////////////////////////////////////////////////////////// +// 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 // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include + +#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_inputSampleRate = 96000; + m_inputFrequencyOffset = 0; + m_rfBandwidth = 10000.0; + m_demodGain = 1.0; + m_volume = 1.0; + m_baudRate = 4800; + m_fmDeviation = 5000.0; + m_squelchGate = 5; // 10s of ms at 48000 Hz sample rate. Corresponds to 2400 for AGC attack + m_squelch = -30.0; + m_audioMute = false; + m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); + m_enableCosineFiltering = false; + m_syncOrConstellation = false; + m_slot1On = true; + m_slot2On = false; + m_tdmaStereo = false; + m_pllLock = true; + m_udpCopyAudio = false; + m_udpAddress = "127.0.0.1"; + m_udpPort = 9999; + m_rgbColor = QColor(0, 255, 255).rgb(); +} + +QByteArray DSDDemodSettings::serialize() const +{ + SimpleSerializer s(1); + s.writeS32(1, m_inputSampleRate); + s.writeS32(2, m_rfBandwidth/100.0); + s.writeS32(3, m_demodGain*100.0); + s.writeS32(4, m_fmDeviation/100.0); + s.writeS32(5, m_squelch); + 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()); + } + + 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; + + if (m_channelMarker) { + d.readBlob(17, &bytetmp); + m_channelMarker->deserialize(bytetmp); + } + + d.readS32(1, &m_inputSampleRate, 96000); + d.readS32(2, &tmp, 4); + m_rfBandwidth = tmp * 100.0; + d.readS32(3, &tmp, 3); + m_demodGain = tmp / 100.0; + d.readS32(4, &tmp, 20); + m_fmDeviation = tmp * 100.0; + d.readS32(5, &tmp, -40); + m_squelch = tmp; + 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); + + return true; + } + else + { + resetToDefaults(); + return false; + } +} + diff --git a/plugins/channelrx/demoddsd/demoddsdsettings.h b/plugins/channelrx/demoddsd/dsddemodsettings.h similarity index 87% rename from plugins/channelrx/demoddsd/demoddsdsettings.h rename to plugins/channelrx/demoddsd/dsddemodsettings.h index 544e3e3ea..4ccf441d5 100644 --- a/plugins/channelrx/demoddsd/demoddsdsettings.h +++ b/plugins/channelrx/demoddsd/dsddemodsettings.h @@ -14,8 +14,8 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// -#ifndef PLUGINS_CHANNELRX_DEMODDSD_DEMODDSDSETTINGS_H_ -#define PLUGINS_CHANNELRX_DEMODDSD_DEMODDSDSETTINGS_H_ +#ifndef PLUGINS_CHANNELRX_DEMODDSD_DSDDEMODSETTINGS_H_ +#define PLUGINS_CHANNELRX_DEMODDSD_DSDDEMODSETTINGS_H_ #include @@ -25,11 +25,11 @@ struct DSDDemodSettings { int m_inputSampleRate; qint64 m_inputFrequencyOffset; - int m_rfBandwidth; - int m_demodGain; - int m_volume; + Real m_rfBandwidth; + Real m_demodGain; + Real m_volume; int m_baudRate; - int m_fmDeviation; + Real m_fmDeviation; int m_squelchGate; Real m_squelch; bool m_audioMute; @@ -43,6 +43,7 @@ struct DSDDemodSettings bool m_udpCopyAudio; QString m_udpAddress; quint16 m_udpPort; + quint32 m_rgbColor; Serializable *m_channelMarker; Serializable *m_scopeGUI; @@ -56,4 +57,4 @@ struct DSDDemodSettings }; -#endif /* PLUGINS_CHANNELRX_DEMODDSD_DEMODDSDSETTINGS_H_ */ +#endif /* PLUGINS_CHANNELRX_DEMODDSD_DSDDEMODSETTINGS_H_ */