1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 04:11:48 -05:00

Tx ph.1: new AM modulator plugin (1)

This commit is contained in:
f4exb 2016-10-20 00:42:21 +02:00
parent 181b7434fd
commit be9519de71
6 changed files with 639 additions and 1 deletions

View File

@ -2,7 +2,7 @@
#include <QAction>
#include "plugin/pluginapi.h"
#include "../../channelrx/demodam/amdemodgui.h"
#include "amdemodgui.h"
#include "amdemodplugin.h"
const PluginDescriptor AMDemodPlugin::m_pluginDescriptor = {

View File

@ -0,0 +1,132 @@
///////////////////////////////////////////////////////////////////////////////////
// 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_AMMOD_H_
#define PLUGINS_CHANNELTX_MODAM_AMMOD_H_
#include <QMutex>
#include <vector>
#include "dsp/basebandsamplesource.h"
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "dsp/lowpass.h"
#include "dsp/movingaverage.h"
#include "dsp/agc.h"
#include "audio/audiofifo.h"
#include "util/message.h"
class AMMod : public BasebandSampleSource {
Q_OBJECT
public:
AMMod();
~AMMod();
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, int modPercent, bool audioMute);
virtual void pull(Sample& sample);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
private:
class MsgConfigureAMDemod : public Message {
MESSAGE_CLASS_DECLARATION
public:
Real getRFBandwidth() const { return m_rfBandwidth; }
Real getAFBandwidth() const { return m_afBandwidth; }
Real getModPercent() const { return m_modPercent; }
bool getAudioMute() const { return m_audioMute; }
static MsgConfigureAMDemod* create(Real rfBandwidth, Real afBandwidth, int modPercent, bool audioMute)
{
return new MsgConfigureAMDemod(rfBandwidth, afBandwidth, modPercent, audioMute);
}
private:
Real m_rfBandwidth;
Real m_afBandwidth;
Real m_modPercent;
bool m_audioMute;
MsgConfigureAMDemod(Real rfBandwidth, Real afBandwidth, int modPercent, bool audioMute) :
Message(),
m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth),
m_modPercent(modPercent),
m_audioMute(audioMute)
{ }
};
struct AudioSample {
qint16 l;
qint16 r;
};
typedef std::vector<AudioSample> AudioVector;
enum RateState {
RSInitialFill,
RSRunning
};
struct Config {
int m_inputSampleRate;
qint64 m_inputFrequencyOffset;
Real m_rfBandwidth;
Real m_afBandwidth;
int m_modPercent;
quint32 m_audioSampleRate;
bool m_audioMute;
Config() :
m_inputSampleRate(-1),
m_inputFrequencyOffset(0),
m_rfBandwidth(-1),
m_afBandwidth(-1),
m_modPercent(20),
m_audioSampleRate(0),
m_audioMute(false)
{ }
};
Config m_config;
Config m_running;
NCO m_nco;
Interpolator m_interpolator;
Real m_interpolatorDistance;
Real m_interpolatorDistanceRemain;
Lowpass<Real> m_lowpass;
Real m_magsq;
MovingAverage<Real> m_movingAverage;
SimpleAGC m_volumeAGC;
AudioVector m_audioBuffer;
uint m_audioBufferFill;
AudioFifo m_audioFifo;
SampleVector m_sampleBuffer;
QMutex m_settingsMutex;
void apply();
};
#endif /* PLUGINS_CHANNELTX_MODAM_AMMOD_H_ */

View File

@ -0,0 +1,93 @@
///////////////////////////////////////////////////////////////////////////////////
// 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_AMMODGUI_H_
#define PLUGINS_CHANNELTX_MODAM_AMMODGUI_H_
#include "gui/rollupwidget.h"
#include "plugin/plugingui.h"
#include "dsp/channelmarker.h"
#include "dsp/movingaverage.h"
class PluginAPI;
class DeviceSinkAPI;
class ThreadedBasebandSampleSource;
class UpChannelizer;
class AMMod;
namespace Ui {
class AMModGUI;
}
class AMModGUI : public RollupWidget, public PluginGUI {
Q_OBJECT
public:
static AMModGUI* create(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI);
void destroy();
void setName(const QString& name);
QString getName() const;
virtual qint64 getCenterFrequency() const;
virtual void setCenterFrequency(qint64 centerFrequency);
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual bool handleMessage(const Message& message);
static const QString m_channelID;
private slots:
void viewChanged();
void on_deltaFrequency_changed(quint64 value);
void on_deltaMinus_toggled(bool minus);
void on_rfBW_valueChanged(int value);
void on_afBW_valueChanged(int value);
void on_modPercent_valueChanged(int value);
void on_audioMute_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void tick();
private:
Ui::AMModGUI* ui;
PluginAPI* m_pluginAPI;
DeviceSinkAPI* m_deviceAPI;
ChannelMarker m_channelMarker;
bool m_basicSettingsShown;
bool m_doApplySettings;
ThreadedBasebandSampleSource* m_threadedChannelizer;
UpChannelizer* m_channelizer;
AMMod* m_amDemod;
MovingAverage<Real> m_channelPowerDbAvg;
static const int m_rfBW[];
explicit AMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* parent = NULL);
virtual ~AMModGUI();
void blockApplySettings(bool block);
void applySettings();
void leaveEvent(QEvent*);
void enterEvent(QEvent*);
};
#endif /* PLUGINS_CHANNELTX_MODAM_AMMODGUI_H_ */

View File

@ -0,0 +1,326 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AMModGUI</class>
<widget class="RollupWidget" name="AMModGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>257</width>
<height>143</height>
</rect>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="windowTitle">
<string>AM Modulator</string>
</property>
<widget class="QWidget" name="settingsContainer" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>235</width>
<height>121</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="deltaFreqPowLayout">
<item>
<layout class="QHBoxLayout" name="deltaFrequencyLayout">
<item>
<widget class="QToolButton" name="deltaMinus">
<property name="toolTip">
<string>Frequency shift direction</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<selectedoff>:/plus.png</selectedoff>
<selectedon>:/minus.png</selectedon>
</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="ValueDial" name="deltaFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>SizeVerCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Hz </string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="channelPowerLayout">
<item>
<widget class="QLabel" name="channelPower">
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>0.0</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="channelPowerUnits">
<property name="text">
<string> dB</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="audioMute">
<property name="toolTip">
<string>Mute/Unmute audio</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/sound_on.png</normaloff>
<normalon>:/sound_off.png</normalon>:/sound_on.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="rfBandwidthLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>RF BW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="rfBW">
<property name="toolTip">
<string>Demodulator (RF) bandwidth</string>
</property>
<property name="maximum">
<number>8</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rfBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>12.5kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="afBandwidthLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>AF BW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="afBW">
<property name="toolTip">
<string>Audio bandwidth</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="afBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>3 kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="modPercentLayout">
<item>
<widget class="QLabel" name="pLabel">
<property name="text">
<string>Mod%</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="modPercent">
<property name="toolTip">
<string>Modulation percentage</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="modPercentText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>20</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>RollupWidget</class>
<extends>QWidget</extends>
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////////
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QtPlugin>
#include <QAction>
#include "plugin/pluginapi.h"
#include "ammodplugin.h"
const PluginDescriptor AMModPlugin::m_pluginDescriptor = {
QString("AM Modulator"),
QString("2.2.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
QString("https://github.com/f4exb/sdrangel")
};
AMModPlugin::AMModPlugin(QObject* parent) :
QObject(parent)
{
}
const PluginDescriptor& AMModPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}

View File

@ -0,0 +1,47 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 INCLUDE_AMMODPLUGIN_H
#define INCLUDE_AMMODPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class DeviceSinkAPI;
class AMModPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "sdrangel.channeltx.ammod")
public:
explicit AMModPlugin(QObject* parent = NULL);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
PluginGUI* createTxChannel(const QString& channelName, DeviceSinkAPI *deviceAPI);
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
private slots:
void createInstanceModAM(DeviceSinkAPI *deviceAPI);
};
#endif // INCLUDE_AMMODPLUGIN_H