From 0ee830f403828ab528244f45a209c9e04faa296a Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 11 Oct 2017 08:33:53 +0200 Subject: [PATCH] NFM modulator: use settings in GUI (1) --- plugins/channeltx/modnfm/nfmmod.cpp | 6 +-- plugins/channeltx/modnfm/nfmmod.h | 16 ++++---- plugins/channeltx/modnfm/nfmmodgui.cpp | 52 ++++++++++++++++++-------- plugins/channeltx/modnfm/nfmmodgui.h | 2 + 4 files changed, 51 insertions(+), 25 deletions(-) diff --git a/plugins/channeltx/modnfm/nfmmod.cpp b/plugins/channeltx/modnfm/nfmmod.cpp index 3078e7785..280df6e8d 100644 --- a/plugins/channeltx/modnfm/nfmmod.cpp +++ b/plugins/channeltx/modnfm/nfmmod.cpp @@ -93,7 +93,7 @@ void NFMMod::configure(MessageQueue* messageQueue, bool audioMute, bool playLoop, bool ctcssOn, - float ctcssFrequency) + int ctcssFrequencyIndex) { Message* cmd = MsgConfigureNFMMod::create(rfBandwidth, afBandwidth, @@ -103,7 +103,7 @@ void NFMMod::configure(MessageQueue* messageQueue, audioMute, playLoop, ctcssOn, - ctcssFrequency); + ctcssFrequencyIndex); messageQueue->push(cmd); } @@ -316,7 +316,7 @@ bool NFMMod::handleMessage(const Message& cmd) m_config.m_channelMute = cfg.getChannelMute(); m_config.m_playLoop = cfg.getPlayLoop(); m_config.m_ctcssOn = cfg.getCTCSSOn(); - m_config.m_ctcssFrequency = cfg.getCTCSSFrequency(); + m_config.m_ctcssFrequency = NFMModSettings::getCTCSSFreq(cfg.getCTCSSFrequencyIndex()); apply(); diff --git a/plugins/channeltx/modnfm/nfmmod.h b/plugins/channeltx/modnfm/nfmmod.h index db4856cfd..399c81a65 100644 --- a/plugins/channeltx/modnfm/nfmmod.h +++ b/plugins/channeltx/modnfm/nfmmod.h @@ -34,6 +34,8 @@ #include "audio/audiofifo.h" #include "util/message.h" +#include "nfmmodsettings.h" + class NFMMod : public BasebandSampleSource { Q_OBJECT @@ -187,7 +189,7 @@ public: bool channelMute, bool playLoop, bool ctcssOn, - float ctcssFrequency); + int ctcssFrequencyIndex); virtual void pull(Sample& sample); virtual void pullAudio(int nbSamples); @@ -223,7 +225,7 @@ private: bool getChannelMute() const { return m_channelMute; } bool getPlayLoop() const { return m_playLoop; } bool getCTCSSOn() const { return m_ctcssOn; } - float getCTCSSFrequency() const { return m_ctcssFrequency; } + float getCTCSSFrequencyIndex() const { return m_ctcssFrequencyIndex; } static MsgConfigureNFMMod* create(Real rfBandwidth, Real afBandwidth, @@ -233,7 +235,7 @@ private: bool channelMute, bool playLoop, bool ctcssOn, - float ctcssFrequency) + int ctcssFrequencyIndex) { return new MsgConfigureNFMMod(rfBandwidth, afBandwidth, @@ -243,7 +245,7 @@ private: channelMute, playLoop, ctcssOn, - ctcssFrequency); + ctcssFrequencyIndex); } private: @@ -255,7 +257,7 @@ private: bool m_channelMute; bool m_playLoop; bool m_ctcssOn; - float m_ctcssFrequency; + int m_ctcssFrequencyIndex; MsgConfigureNFMMod(Real rfBandwidth, Real afBandwidth, @@ -265,7 +267,7 @@ private: bool channelMute, bool playLoop, bool ctcssOn, - float ctcssFrequency) : + int ctcssFrequencyIndex) : Message(), m_rfBandwidth(rfBandwidth), m_afBandwidth(afBandwidth), @@ -275,7 +277,7 @@ private: m_channelMute(channelMute), m_playLoop(playLoop), m_ctcssOn(ctcssOn), - m_ctcssFrequency(ctcssFrequency) + m_ctcssFrequencyIndex(ctcssFrequencyIndex) { } }; diff --git a/plugins/channeltx/modnfm/nfmmodgui.cpp b/plugins/channeltx/modnfm/nfmmodgui.cpp index 09e469538..efcf10751 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.cpp +++ b/plugins/channeltx/modnfm/nfmmodgui.cpp @@ -214,45 +214,54 @@ void NFMModGUI::handleSourceMessages() void NFMModGUI::on_deltaFrequency_changed(qint64 value) { m_channelMarker.setCenterFrequency(value); + m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); + applySettings(); } void NFMModGUI::on_rfBW_currentIndexChanged(int index) { - m_channelMarker.setBandwidth(m_rfBW[index]); + m_channelMarker.setBandwidth(NFMModSettings::getRFBW(index)); + m_settings.m_rfBandwidth = NFMModSettings::getRFBW(index); applySettings(); } void NFMModGUI::on_afBW_valueChanged(int value) { ui->afBWText->setText(QString("%1k").arg(value)); + m_settings.m_afBandwidth = value * 1000.0; applySettings(); } void NFMModGUI::on_fmDev_valueChanged(int value) { ui->fmDevText->setText(QString("%1k").arg(value / 10.0, 0, 'f', 1)); + m_settings.m_fmDeviation = value * 100.0; applySettings(); } void NFMModGUI::on_volume_valueChanged(int value) { ui->volumeText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1)); + m_settings.m_volumeFactor = value / 10.0; applySettings(); } void NFMModGUI::on_toneFrequency_valueChanged(int value) { ui->toneFrequencyText->setText(QString("%1k").arg(value / 100.0, 0, 'f', 2)); + m_settings.m_toneFrequency = value * 10.0; applySettings(); } -void NFMModGUI::on_channelMute_toggled(bool checked __attribute__((unused))) +void NFMModGUI::on_channelMute_toggled(bool checked) { + m_settings.m_channelMute = checked; applySettings(); } -void NFMModGUI::on_playLoop_toggled(bool checked __attribute__((unused))) +void NFMModGUI::on_playLoop_toggled(bool checked) { + m_settings.m_playLoop = checked; applySettings(); } @@ -325,13 +334,15 @@ void NFMModGUI::on_showFileDialog_clicked(bool checked __attribute__((unused))) } } -void NFMModGUI::on_ctcss_currentIndexChanged(int index __attribute__((unused))) +void NFMModGUI::on_ctcss_currentIndexChanged(int index) { + m_settings.m_ctcssIndex = index; applySettings(); } -void NFMModGUI::on_ctcssOn_toggled(bool checked __attribute__((unused))) +void NFMModGUI::on_ctcssOn_toggled(bool checked) { + m_settings.m_ctcssOn = checked; applySettings(); } @@ -458,16 +469,27 @@ void NFMModGUI::applySettings() ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); - m_nfmMod->configure(m_nfmMod->getInputMessageQueue(), - m_rfBW[ui->rfBW->currentIndex()], - ui->afBW->value() * 1000.0, - ui->fmDev->value() * 100.0f, // value is in '100 Hz - ui->toneFrequency->value() * 10.0f, - ui->volume->value() / 10.0f, - ui->channelMute->isChecked(), - ui->playLoop->isChecked(), - ui->ctcssOn->isChecked(), - m_ctcssTones[ui->ctcss->currentIndex()]); + m_nfmMod->configure(m_nfmMod->getInputMessageQueue(), + m_settings.m_rfBandwidth, + m_settings.m_afBandwidth, + m_settings.m_fmDeviation, // value is in '100 Hz + m_settings.m_toneFrequency, + m_settings.m_volumeFactor, + m_settings.m_channelMute, + m_settings.m_playLoop, + m_settings.m_ctcssOn, + m_settings.m_ctcssIndex); + +// m_nfmMod->configure(m_nfmMod->getInputMessageQueue(), +// m_rfBW[ui->rfBW->currentIndex()], +// ui->afBW->value() * 1000.0, +// ui->fmDev->value() * 100.0f, // value is in '100 Hz +// ui->toneFrequency->value() * 10.0f, +// ui->volume->value() / 10.0f, +// ui->channelMute->isChecked(), +// ui->playLoop->isChecked(), +// ui->ctcssOn->isChecked(), +// m_ctcssTones[ui->ctcss->currentIndex()]); } } diff --git a/plugins/channeltx/modnfm/nfmmodgui.h b/plugins/channeltx/modnfm/nfmmodgui.h index 7cb026320..b80f9c909 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.h +++ b/plugins/channeltx/modnfm/nfmmodgui.h @@ -24,6 +24,7 @@ #include "util/messagequeue.h" #include "nfmmod.h" +#include "nfmmodsettings.h" class PluginAPI; class DeviceSinkAPI; @@ -90,6 +91,7 @@ private: PluginAPI* m_pluginAPI; DeviceSinkAPI* m_deviceAPI; ChannelMarker m_channelMarker; + NFMModSettings m_settings; bool m_basicSettingsShown; bool m_doApplySettings;