1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-23 00:18:37 -05:00

AM modulator: created settings class

This commit is contained in:
f4exb 2017-10-09 18:27:47 +02:00
parent e570e0d354
commit 1ae75824ac
4 changed files with 244 additions and 80 deletions

View File

@ -1,43 +1,45 @@
project(modam)
set(modam_SOURCES
ammod.cpp
ammodgui.cpp
ammodplugin.cpp
)
set(modam_HEADERS
ammod.h
ammodgui.h
ammodplugin.h
)
set(modam_FORMS
ammodgui.ui
)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
)
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
qt5_wrap_ui(modam_FORMS_HEADERS ${modam_FORMS})
add_library(modam SHARED
${modam_SOURCES}
${modam_HEADERS_MOC}
${modam_FORMS_HEADERS}
)
target_link_libraries(modam
${QT_LIBRARIES}
sdrbase
)
qt5_use_modules(modam Core Widgets)
project(modam)
set(modam_SOURCES
ammod.cpp
ammodgui.cpp
ammodplugin.cpp
ammodsettings.cpp
)
set(modam_HEADERS
ammod.h
ammodgui.h
ammodplugin.h
ammodsettings.h
)
set(modam_FORMS
ammodgui.ui
)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
)
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
qt5_wrap_ui(modam_FORMS_HEADERS ${modam_FORMS})
add_library(modam SHARED
${modam_SOURCES}
${modam_HEADERS_MOC}
${modam_FORMS_HEADERS}
)
target_link_libraries(modam
${QT_LIBRARIES}
sdrbase
)
qt5_use_modules(modam Core Widgets)
install(TARGETS modam DESTINATION lib/plugins/channeltx)

View File

@ -0,0 +1,109 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "ammodsettings.h"
AMModSettings::AMModSettings() :
m_channelMarker(0)
{
resetToDefaults();
}
void AMModSettings::resetToDefaults()
{
m_basebandSampleRate = 48000;
m_outputSampleRate = 48000;
m_inputFrequencyOffset = 0;
m_rfBandwidth = 12500.0;
m_modFactor = 0.2f;
m_toneFrequency = 1000.0f;
m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
m_volumeFactor = 1.0f;
m_channelMute = false;
m_playLoop = false;
}
QByteArray AMModSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_inputFrequencyOffset);
s.writeS32(2, m_rfBandwidth / 100.0);
s.writeS32(3, m_toneFrequency / 10.0);
s.writeS32(4, m_modFactor * 100.0);
s.writeU32(5, m_rgbColor);
s.writeS32(6, m_volumeFactor * 10.0);
if (m_cwKeyerGUI) {
s.writeBlob(7, m_cwKeyerGUI->serialize());
}
if (m_channelMarker) {
s.writeBlob(8, m_channelMarker->serialize());
}
return s.final();
}
bool AMModSettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
{
QByteArray bytetmp;
quint32 u32tmp;
qint32 tmp;
d.readS32(1, &tmp, 0);
m_inputFrequencyOffset = tmp;
d.readS32(2, &tmp, 125);
m_rfBandwidth = tmp * 100.0;
d.readS32(3, &tmp, 100);
m_toneFrequency = tmp * 10;
d.readS32(4, &tmp, 20);
m_modFactor = tmp * 100;
d.readU32(5, &m_rgbColor);
d.readS32(6, &tmp, 10);
m_volumeFactor = tmp * 10.0;
if (m_cwKeyerGUI) {
d.readBlob(7, &bytetmp);
m_cwKeyerGUI->deserialize(bytetmp);
}
if (m_channelMarker) {
d.readBlob(8, &bytetmp);
m_channelMarker->deserialize(bytetmp);
}
return true;
}
else
{
resetToDefaults();
return false;
}
}

View File

@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_MODAM_AMMODSETTINGS_H_
#define PLUGINS_CHANNELTX_MODAM_AMMODSETTINGS_H_
#include <QByteArray>
class Serializable;
struct AMModSettings
{
int m_basebandSampleRate;
int m_outputSampleRate;
qint64 m_inputFrequencyOffset;
Real m_rfBandwidth;
float m_modFactor;
float m_toneFrequency;
float m_volumeFactor;
quint32 m_audioSampleRate;
bool m_channelMute;
bool m_playLoop;
quint32 m_rgbColor;
Serializable *m_channelMarker;
Serializable *m_cwKeyerGUI;
AMModSettings();
void resetToDefaults();
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
void setCWKeyerGUI(Serializable *cwKeyerGUI) { m_cwKeyerGUI = cwKeyerGUI; }
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
};
#endif /* PLUGINS_CHANNELTX_MODAM_AMMODSETTINGS_H_ */

View File

@ -1,38 +1,40 @@
#--------------------------------------------------------
#
# Pro file for Android and Windows builds with Qt Creator
#
#--------------------------------------------------------
TEMPLATE = lib
CONFIG += plugin
QT += core gui widgets multimedia
TARGET = modam
DEFINES += USE_SSE2=1
QMAKE_CXXFLAGS += -msse2
DEFINES += USE_SSE4_1=1
QMAKE_CXXFLAGS += -msse4.1
QMAKE_CXXFLAGS += -std=c++11
INCLUDEPATH += $$PWD
INCLUDEPATH += ../../../sdrbase
CONFIG(Release):build_subdir = release
CONFIG(Debug):build_subdir = debug
SOURCES += ammod.cpp\
ammodgui.cpp\
ammodplugin.cpp
HEADERS += ammod.h\
ammodgui.h\
ammodplugin.h
FORMS += ammodgui.ui
LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase
RESOURCES = ../../../sdrbase/resources/res.qrc
#--------------------------------------------------------
#
# Pro file for Android and Windows builds with Qt Creator
#
#--------------------------------------------------------
TEMPLATE = lib
CONFIG += plugin
QT += core gui widgets multimedia
TARGET = modam
DEFINES += USE_SSE2=1
QMAKE_CXXFLAGS += -msse2
DEFINES += USE_SSE4_1=1
QMAKE_CXXFLAGS += -msse4.1
QMAKE_CXXFLAGS += -std=c++11
INCLUDEPATH += $$PWD
INCLUDEPATH += ../../../sdrbase
CONFIG(Release):build_subdir = release
CONFIG(Debug):build_subdir = debug
SOURCES += ammod.cpp\
ammodgui.cpp\
ammodplugin.cpp\
ammodsettings.cpp
HEADERS += ammod.h\
ammodgui.h\
ammodplugin.h\
ammodsettings.h
FORMS += ammodgui.ui
LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase
RESOURCES = ../../../sdrbase/resources/res.qrc