diff --git a/plugins/channelrx/demodam/amdemodsettings.h b/plugins/channelrx/demodam/amdemodsettings.h index abbb12556..b07bc0c74 100644 --- a/plugins/channelrx/demodam/amdemodsettings.h +++ b/plugins/channelrx/demodam/amdemodsettings.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2015 Edouard Griffiths, F4EXB. // +// Copyright (C) 2017 Edouard Griffiths, F4EXB. // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // diff --git a/plugins/channelrx/demodssb/CMakeLists.txt b/plugins/channelrx/demodssb/CMakeLists.txt index f1b1449f1..53cf45296 100644 --- a/plugins/channelrx/demodssb/CMakeLists.txt +++ b/plugins/channelrx/demodssb/CMakeLists.txt @@ -3,12 +3,14 @@ project(ssb) set(ssb_SOURCES ssbdemod.cpp ssbdemodgui.cpp + ssbdemodsettings.cpp ssbplugin.cpp ) set(ssb_HEADERS ssbdemod.h ssbdemodgui.h + ssbdemodsettings.h ssbplugin.h ) diff --git a/plugins/channelrx/demodssb/demodssb.pro b/plugins/channelrx/demodssb/demodssb.pro index d65971658..6b347d66f 100644 --- a/plugins/channelrx/demodssb/demodssb.pro +++ b/plugins/channelrx/demodssb/demodssb.pro @@ -25,10 +25,12 @@ CONFIG(Debug):build_subdir = debug SOURCES += ssbdemod.cpp\ ssbdemodgui.cpp\ + ssbdemodsettings.cpp\ ssbplugin.cpp HEADERS += ssbdemod.h\ ssbdemodgui.h\ + ssbdemodsettings.h\ ssbplugin.h FORMS += ssbdemodgui.ui diff --git a/plugins/channelrx/demodssb/ssbdemodsettings.cpp b/plugins/channelrx/demodssb/ssbdemodsettings.cpp new file mode 100644 index 000000000..ff949ddbc --- /dev/null +++ b/plugins/channelrx/demodssb/ssbdemodsettings.cpp @@ -0,0 +1,120 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB. // +// // +// This program is free software; 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 "dsp/dspengine.h" +#include "util/simpleserializer.h" +#include "settings/serializable.h" +#include "ssbdemodsettings.h" + +SSBDemodSettings::SSBDemodSettings() : + m_channelMarker(0), + m_spectrumGUI(0) +{ + resetToDefaults(); +} + +void SSBDemodSettings::resetToDefaults() +{ + m_audioBinaural = false; + m_audioFlipChannels = false; + m_dsb = false; + m_audioMute = false; + m_agc = false; + m_agcClamping = false; + m_agcPowerThreshold = -40; + m_agcThresholdGate = 4; + m_agcTimeLog2 = 7; + m_rfBandwidth = 3000; + m_lowCutoff = 300; + m_volume = 3.0; + m_spanLog2 = 3; + m_inputSampleRate = 96000; + m_inputFrequencyOffset = 0; +} + +QByteArray SSBDemodSettings::serialize() const +{ + SimpleSerializer s(1); + s.writeS32(1, m_inputFrequencyOffset); + s.writeS32(2, m_rfBandwidth / 100.0); + s.writeS32(3, m_volume * 10.0); + + if (m_spectrumGUI) { + s.writeBlob(4, m_spectrumGUI->serialize()); + } + + s.writeU32(5, m_rgbColor); + s.writeS32(6, m_lowCutoff / 100.0); + s.writeS32(7, m_spanLog2); + s.writeBool(8, m_audioBinaural); + s.writeBool(9, m_audioFlipChannels); + s.writeBool(10, m_dsb); + s.writeBool(11, m_agc); + s.writeS32(12, m_agcTimeLog2); + s.writeS32(13, m_agcPowerThreshold); + s.writeS32(14, m_agcThresholdGate); + s.writeBool(15, m_agcClamping); + return s.final(); +} + +bool SSBDemodSettings::deserialize(const QByteArray& data) +{ + SimpleDeserializer d(data); + + if(!d.isValid()) + { + resetToDefaults(); + return false; + } + + if(d.getVersion() == 1) + { + QByteArray bytetmp; + qint32 tmp; + QString strtmp; + + d.readS32(1, &m_inputFrequencyOffset, 0); + d.readS32(2, &tmp, 30); + m_rfBandwidth = tmp * 100.0; + d.readS32(3, &tmp, 30); + m_volume = tmp / 10.0; + + if (m_spectrumGUI) { + d.readBlob(4, &bytetmp); + m_spectrumGUI->deserialize(bytetmp); + } + + d.readU32(5, &m_rgbColor); + d.readS32(6, &tmp, 30); + m_lowCutoff = tmp * 100.0; + d.readS32(7, &m_spanLog2, 3); + d.readBool(8, &m_audioBinaural, false); + d.readBool(9, &m_audioFlipChannels, false); + d.readBool(10, &m_dsb, false); + d.readBool(11, &m_agc, false); + d.readS32(12, &m_agcTimeLog2, 7); + d.readS32(13, &m_agcPowerThreshold, -40); + d.readS32(14, &m_agcThresholdGate, 4); + d.readBool(15, &m_agcClamping, false); + + return true; + } + else + { + resetToDefaults(); + return false; + } +} diff --git a/plugins/channelrx/demodssb/ssbdemodsettings.h b/plugins/channelrx/demodssb/ssbdemodsettings.h new file mode 100644 index 000000000..30ec2e3ee --- /dev/null +++ b/plugins/channelrx/demodssb/ssbdemodsettings.h @@ -0,0 +1,57 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB. // +// // +// This program is free software; 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef PLUGINS_CHANNELRX_DEMODSSB_SSBDEMODSETTINGS_H_ +#define PLUGINS_CHANNELRX_DEMODSSB_SSBDEMODSETTINGS_H_ + +#include + +class Serializable; + +struct SSBDemodSettings +{ + int m_inputSampleRate; + qint32 m_inputFrequencyOffset; + Real m_rfBandwidth; + Real m_lowCutoff; + Real m_volume; + int m_spanLog2; + bool m_audioBinaural; + bool m_audioFlipChannels; + bool m_dsb; + bool m_audioMute; + bool m_agc; + bool m_agcClamping; + int m_agcTimeLog2; + int m_agcPowerThreshold; + int m_agcThresholdGate; + QString m_udpAddress; + quint16 m_udpPort; + quint32 m_rgbColor; + + Serializable *m_channelMarker; + Serializable *m_spectrumGUI; + + SSBDemodSettings(); + void resetToDefaults(); + void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; } + void setSpectrumGUI(Serializable *spectrumGUI) { m_spectrumGUI = spectrumGUI; } + QByteArray serialize() const; + bool deserialize(const QByteArray& data); +}; + + +#endif /* PLUGINS_CHANNELRX_DEMODSSB_SSBDEMODSETTINGS_H_ */