From 47eb55a3196fc388f4131199c5ea5f469b3024ed Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 30 Nov 2016 16:42:06 +0100 Subject: [PATCH] AM Demodulator: removed useless AF lowpass filtering and its associated GUI items --- plugins/channelrx/demodam/amdemod.cpp | 21 ++----- plugins/channelrx/demodam/amdemod.h | 17 ++---- plugins/channelrx/demodam/amdemodgui.cpp | 26 +++------ plugins/channelrx/demodam/amdemodgui.h | 3 - plugins/channelrx/demodam/amdemodgui.ui | 63 +++------------------ plugins/channelrx/demodam/amdemodplugin.cpp | 2 +- plugins/channeltx/modam/ammod.h | 1 - plugins/channeltx/modam/ammodgui.cpp | 2 +- 8 files changed, 27 insertions(+), 108 deletions(-) diff --git a/plugins/channelrx/demodam/amdemod.cpp b/plugins/channelrx/demodam/amdemod.cpp index 76cb810dc..c81088e27 100644 --- a/plugins/channelrx/demodam/amdemod.cpp +++ b/plugins/channelrx/demodam/amdemod.cpp @@ -36,8 +36,7 @@ AMDemod::AMDemod() : m_config.m_inputSampleRate = 96000; m_config.m_inputFrequencyOffset = 0; - m_config.m_rfBandwidth = 12500; - m_config.m_afBandwidth = 3000; + m_config.m_rfBandwidth = 5000; m_config.m_squelch = -40.0; m_config.m_volume = 2.0; m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); @@ -59,9 +58,9 @@ AMDemod::~AMDemod() DSPEngine::instance()->removeAudioSink(&m_audioFifo); } -void AMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioMute) +void AMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real volume, Real squelch, bool audioMute) { - Message* cmd = MsgConfigureAMDemod::create(rfBandwidth, afBandwidth, volume, squelch, audioMute); + Message* cmd = MsgConfigureAMDemod::create(rfBandwidth, volume, squelch, audioMute); messageQueue->push(cmd); } @@ -150,7 +149,6 @@ bool AMDemod::handleMessage(const Message& cmd) MsgConfigureAMDemod& cfg = (MsgConfigureAMDemod&) cmd; m_config.m_rfBandwidth = cfg.getRFBandwidth(); - m_config.m_afBandwidth = cfg.getAFBandwidth(); m_config.m_volume = cfg.getVolume(); m_config.m_squelch = cfg.getSquelch(); m_config.m_audioMute = cfg.getAudioMute(); @@ -159,7 +157,6 @@ bool AMDemod::handleMessage(const Message& cmd) qDebug() << "AMDemod::handleMessage: MsgConfigureAMDemod:" << " m_rfBandwidth: " << m_config.m_rfBandwidth - << " m_afBandwidth: " << m_config.m_afBandwidth << " m_volume: " << m_config.m_volume << " m_squelch: " << m_config.m_squelch << " m_audioMute: " << m_config.m_audioMute; @@ -182,7 +179,8 @@ void AMDemod::apply() } if((m_config.m_inputSampleRate != m_running.m_inputSampleRate) || - (m_config.m_rfBandwidth != m_running.m_rfBandwidth)) + (m_config.m_rfBandwidth != m_running.m_rfBandwidth) || + (m_config.m_audioSampleRate != m_running.m_audioSampleRate)) { m_settingsMutex.lock(); m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_rfBandwidth / 2.2); @@ -191,14 +189,6 @@ void AMDemod::apply() m_settingsMutex.unlock(); } - if((m_config.m_afBandwidth != m_running.m_afBandwidth) || - (m_config.m_audioSampleRate != m_running.m_audioSampleRate)) - { - m_settingsMutex.lock(); - m_lowpass.create(21, m_config.m_audioSampleRate, m_config.m_afBandwidth); - m_settingsMutex.unlock(); - } - if(m_config.m_squelch != m_running.m_squelch) { m_squelchLevel = pow(10.0, m_config.m_squelch / 20.0); @@ -208,7 +198,6 @@ void AMDemod::apply() m_running.m_inputSampleRate = m_config.m_inputSampleRate; m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset; m_running.m_rfBandwidth = m_config.m_rfBandwidth; - m_running.m_afBandwidth = m_config.m_afBandwidth; m_running.m_squelch = m_config.m_squelch; m_running.m_volume = m_config.m_volume; m_running.m_audioSampleRate = m_config.m_audioSampleRate; diff --git a/plugins/channelrx/demodam/amdemod.h b/plugins/channelrx/demodam/amdemod.h index 3f634ee60..8bfe5f09c 100644 --- a/plugins/channelrx/demodam/amdemod.h +++ b/plugins/channelrx/demodam/amdemod.h @@ -22,7 +22,6 @@ #include #include "dsp/nco.h" #include "dsp/interpolator.h" -#include "dsp/lowpass.h" #include "dsp/movingaverage.h" #include "dsp/agc.h" #include "audio/audiofifo.h" @@ -34,7 +33,7 @@ public: AMDemod(); ~AMDemod(); - void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioMute); + void configure(MessageQueue* messageQueue, Real rfBandwidth, Real volume, Real squelch, bool audioMute); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void start(); @@ -50,27 +49,24 @@ private: public: Real getRFBandwidth() const { return m_rfBandwidth; } - Real getAFBandwidth() const { return m_afBandwidth; } Real getVolume() const { return m_volume; } Real getSquelch() const { return m_squelch; } bool getAudioMute() const { return m_audioMute; } - static MsgConfigureAMDemod* create(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioMute) + static MsgConfigureAMDemod* create(Real rfBandwidth, Real volume, Real squelch, bool audioMute) { - return new MsgConfigureAMDemod(rfBandwidth, afBandwidth, volume, squelch, audioMute); + return new MsgConfigureAMDemod(rfBandwidth, volume, squelch, audioMute); } private: Real m_rfBandwidth; - Real m_afBandwidth; Real m_volume; Real m_squelch; bool m_audioMute; - MsgConfigureAMDemod(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioMute) : + MsgConfigureAMDemod(Real rfBandwidth, Real volume, Real squelch, bool audioMute) : Message(), m_rfBandwidth(rfBandwidth), - m_afBandwidth(afBandwidth), m_volume(volume), m_squelch(squelch), m_audioMute(audioMute) @@ -92,7 +88,6 @@ private: int m_inputSampleRate; qint64 m_inputFrequencyOffset; Real m_rfBandwidth; - Real m_afBandwidth; Real m_squelch; Real m_volume; quint32 m_audioSampleRate; @@ -102,7 +97,6 @@ private: m_inputSampleRate(-1), m_inputFrequencyOffset(0), m_rfBandwidth(-1), - m_afBandwidth(-1), m_squelch(0), m_volume(0), m_audioSampleRate(0), @@ -117,7 +111,6 @@ private: Interpolator m_interpolator; Real m_interpolatorDistance; Real m_interpolatorDistanceRemain; - Lowpass m_lowpass; Real m_squelchLevel; int m_squelchCount; @@ -163,8 +156,6 @@ private: { Real demod = sqrt(magsq); - demod = m_lowpass.filter(demod); - if (demod < -1) { demod = -1; diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index 98232c795..1f8f5707c 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -35,10 +35,6 @@ const QString AMDemodGUI::m_channelID = "de.maintech.sdrangelove.channel.am"; -const int AMDemodGUI::m_rfBW[] = { - 3000, 4000, 5000, 6250, 8330, 10000, 12500, 15000, 20000, 25000, 40000 -}; - AMDemodGUI* AMDemodGUI::create(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI) { AMDemodGUI* gui = new AMDemodGUI(pluginAPI, deviceAPI); @@ -74,8 +70,7 @@ void AMDemodGUI::resetToDefaults() { blockApplySettings(true); - ui->rfBW->setValue(4); - ui->afBW->setValue(3); + ui->rfBW->setValue(50); ui->volume->setValue(20); ui->squelch->setValue(-40); ui->deltaFrequency->setValue(0); @@ -89,7 +84,7 @@ QByteArray AMDemodGUI::serialize() const SimpleSerializer s(1); s.writeS32(1, m_channelMarker.getCenterFrequency()); s.writeS32(2, ui->rfBW->value()); - s.writeS32(3, ui->afBW->value()); + //s.writeS32(3, ui->afBW->value()); s.writeS32(4, ui->volume->value()); s.writeS32(5, ui->squelch->value()); s.writeU32(7, m_channelMarker.getColor().rgb()); @@ -120,7 +115,7 @@ bool AMDemodGUI::deserialize(const QByteArray& data) d.readS32(2, &tmp, 4); ui->rfBW->setValue(tmp); d.readS32(3, &tmp, 3); - ui->afBW->setValue(tmp); + //ui->afBW->setValue(tmp); d.readS32(4, &tmp, 20); ui->volume->setValue(tmp); d.readS32(5, &tmp, -40); @@ -176,14 +171,8 @@ void AMDemodGUI::on_deltaFrequency_changed(quint64 value) void AMDemodGUI::on_rfBW_valueChanged(int value) { - ui->rfBWText->setText(QString("%1 kHz").arg(m_rfBW[value] / 1000.0)); - m_channelMarker.setBandwidth(m_rfBW[value]); - applySettings(); -} - -void AMDemodGUI::on_afBW_valueChanged(int value) -{ - ui->afBWText->setText(QString("%1 kHz").arg(value)); + ui->rfBWText->setText(QString("%1 kHz").arg(value / 10.0)); + m_channelMarker.setBandwidth(value * 100); applySettings(); } @@ -249,7 +238,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget //m_channelMarker = new ChannelMarker(this); m_channelMarker.setColor(Qt::yellow); - m_channelMarker.setBandwidth(12500); + m_channelMarker.setBandwidth(5000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setVisible(true); @@ -292,8 +281,7 @@ void AMDemodGUI::applySettings() ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0); m_amDemod->configure(m_amDemod->getInputMessageQueue(), - m_rfBW[ui->rfBW->value()], - ui->afBW->value() * 1000.0, + ui->rfBW->value() * 100.0, ui->volume->value() / 10.0, ui->squelch->value(), ui->audioMute->isChecked()); diff --git a/plugins/channelrx/demodam/amdemodgui.h b/plugins/channelrx/demodam/amdemodgui.h index 171c12275..c6e6106a8 100644 --- a/plugins/channelrx/demodam/amdemodgui.h +++ b/plugins/channelrx/demodam/amdemodgui.h @@ -42,7 +42,6 @@ private slots: 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_volume_valueChanged(int value); void on_squelch_valueChanged(int value); void on_audioMute_toggled(bool checked); @@ -64,8 +63,6 @@ private: MovingAverage m_channelPowerDbAvg; bool m_squelchOpen; - static const int m_rfBW[]; - explicit AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent = NULL); virtual ~AMDemodGUI(); diff --git a/plugins/channelrx/demodam/amdemodgui.ui b/plugins/channelrx/demodam/amdemodgui.ui index 0217c5625..a18e7c7d8 100644 --- a/plugins/channelrx/demodam/amdemodgui.ui +++ b/plugins/channelrx/demodam/amdemodgui.ui @@ -7,7 +7,7 @@ 0 0 257 - 143 + 131 @@ -28,7 +28,7 @@ 10 10 235 - 121 + 111 @@ -184,14 +184,17 @@ Demodulator (RF) bandwidth - + 10 + + 200 + 1 - 6 + 50 Qt::Horizontal @@ -207,56 +210,7 @@ - 12.5kHz - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - AF BW - - - - - - - Audio bandwidth - - - 1 - - - 20 - - - 1 - - - 3 - - - Qt::Horizontal - - - - - - - - 50 - 0 - - - - 3 kHz + 5 kHz Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -398,6 +352,7 @@ + diff --git a/plugins/channelrx/demodam/amdemodplugin.cpp b/plugins/channelrx/demodam/amdemodplugin.cpp index 3457f547a..ef0b448ad 100644 --- a/plugins/channelrx/demodam/amdemodplugin.cpp +++ b/plugins/channelrx/demodam/amdemodplugin.cpp @@ -7,7 +7,7 @@ const PluginDescriptor AMDemodPlugin::m_pluginDescriptor = { QString("AM Demodulator"), - QString("2.3.1"), + QString("2.4.0"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/channeltx/modam/ammod.h b/plugins/channeltx/modam/ammod.h index 82962617d..0c3b639be 100644 --- a/plugins/channeltx/modam/ammod.h +++ b/plugins/channeltx/modam/ammod.h @@ -25,7 +25,6 @@ #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" diff --git a/plugins/channeltx/modam/ammodgui.cpp b/plugins/channeltx/modam/ammodgui.cpp index b8c4fe1cc..c57fce2c5 100644 --- a/plugins/channeltx/modam/ammodgui.cpp +++ b/plugins/channeltx/modam/ammodgui.cpp @@ -334,7 +334,7 @@ AMModGUI::AMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pare //m_channelMarker = new ChannelMarker(this); m_channelMarker.setColor(Qt::yellow); - m_channelMarker.setBandwidth(12500); + m_channelMarker.setBandwidth(5000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setVisible(true);