From d6b48ed4d00614722bc6a86d48da6f1b62334e03 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 18 Mar 2017 11:05:28 +0100 Subject: [PATCH] ATV Demod: methods to set RF filters limits and channel marker bandwidth according to other parameters. Set interpolator filter phases to 16 (/3) to improve performance --- plugins/channelrx/demodatv/atvdemod.cpp | 6 +- plugins/channelrx/demodatv/atvdemod.h | 1 + plugins/channelrx/demodatv/atvdemodgui.cpp | 217 ++++++--------------- plugins/channelrx/demodatv/atvdemodgui.h | 2 + 4 files changed, 64 insertions(+), 162 deletions(-) diff --git a/plugins/channelrx/demodatv/atvdemod.cpp b/plugins/channelrx/demodatv/atvdemod.cpp index 3f207b056..c72bf8328 100644 --- a/plugins/channelrx/demodatv/atvdemod.cpp +++ b/plugins/channelrx/demodatv/atvdemod.cpp @@ -610,7 +610,7 @@ void ATVDemod::applySettings() } m_interpolatorDistanceRemain = 0; - m_interpolator.create(48, m_objConfigPrivate.m_intTVSampleRate, m_objRFConfig.m_fltRFBandwidth / 2.2, 3.0); + m_interpolator.create(16, m_objConfigPrivate.m_intTVSampleRate, m_objRFConfig.m_fltRFBandwidth / 2.2, 3.0); m_objSettingsMutex.unlock(); } @@ -657,3 +657,7 @@ int ATVDemod::getSampleRate() return m_objRunning.m_intSampleRate; } +int ATVDemod::getEffectiveSampleRate() +{ + return m_objRFRunning.m_blndecimatorEnable ? m_objRunningPrivate.m_intTVSampleRate : m_objRunning.m_intSampleRate; +} diff --git a/plugins/channelrx/demodatv/atvdemod.h b/plugins/channelrx/demodatv/atvdemod.h index b3b2861fd..aefe49ebb 100644 --- a/plugins/channelrx/demodatv/atvdemod.h +++ b/plugins/channelrx/demodatv/atvdemod.h @@ -144,6 +144,7 @@ public: void setATVScreen(ATVScreen *objScreen); int getSampleRate(); + int getEffectiveSampleRate(); double getMagSq() const { return m_objMagSqAverage.average(); } //!< Beware this is scaled to 2^30 private: diff --git a/plugins/channelrx/demodatv/atvdemodgui.cpp b/plugins/channelrx/demodatv/atvdemodgui.cpp index ca7ed6b61..0b86924a1 100644 --- a/plugins/channelrx/demodatv/atvdemodgui.cpp +++ b/plugins/channelrx/demodatv/atvdemodgui.cpp @@ -174,23 +174,7 @@ bool ATVDemodGUI::handleMessage(const Message& objMessage) { int sampleRate = ((ATVDemod::MsgReportEffectiveSampleRate&)objMessage).getSampleRate(); ui->channelSampleRateText->setText(tr("%1k").arg(sampleRate/1000.0f, 0, 'f', 0)); - - // filter sliders range - if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAML) - { - ui->rfBW->setMaximum(sampleRate / 200000); - ui->rfOppBW->setMaximum(sampleRate / 200000); - } - else if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAMU) - { - ui->rfBW->setMaximum(sampleRate / 200000); - ui->rfOppBW->setMaximum(sampleRate / 200000); - } - else - { - ui->rfBW->setMaximum(sampleRate / 100000); - ui->rfOppBW->setMaximum(sampleRate / 100000); - } + setRFFiltersSlidersRange(sampleRate); return true; } @@ -208,41 +192,7 @@ void ATVDemodGUI::viewChanged() void ATVDemodGUI::channelSampleRateChanged() { qDebug("ATVDemodGUI::channelSampleRateChanged"); - applySettings(); - - - // channel marker - - m_blnDoApplySettings = false; // avoid infinite recursion - - if (ui->rfFiltering->isChecked()) - { - if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAML) - { - m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - m_objChannelMarker.setSidebands(ChannelMarker::vlsb); - } - else if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAMU) - { - m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - m_objChannelMarker.setSidebands(ChannelMarker::vusb); - } - else - { - m_objChannelMarker.setSidebands(ChannelMarker::dsb); - } - } - else - { - m_objChannelMarker.setBandwidth(m_objChannelizer->getInputSampleRate()); - m_objChannelMarker.setSidebands(ChannelMarker::dsb); - - } - - m_blnDoApplySettings = true; applyRFSettings(); } @@ -382,6 +332,52 @@ void ATVDemodGUI::applyRFSettings() } } +void ATVDemodGUI::setChannelMarkerBandwidth() +{ + m_blnDoApplySettings = false; // avoid infinite recursion + + if (ui->rfFiltering->isChecked()) // FFT filter + { + m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); + m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); + + if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAML) { + m_objChannelMarker.setSidebands(ChannelMarker::vlsb); + } else if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAMU) { + m_objChannelMarker.setSidebands(ChannelMarker::vusb); + } else { + m_objChannelMarker.setSidebands(ChannelMarker::vusb); + } + } + else + { + if (ui->decimatorEnable->isChecked()) { + m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); + } else { + m_objChannelMarker.setBandwidth(m_objChannelizer->getInputSampleRate()); + } + + m_objChannelMarker.setSidebands(ChannelMarker::dsb); + } + + m_blnDoApplySettings = true; +} + +void ATVDemodGUI::setRFFiltersSlidersRange(int sampleRate) +{ + // RF filters sliders range + if (ui->rfFiltering->isChecked()) + { + ui->rfBW->setMaximum(sampleRate / 200000); + ui->rfOppBW->setMaximum(sampleRate / 200000); + } + else + { + ui->rfBW->setMaximum(sampleRate / 100000); + ui->rfOppBW->setMaximum(sampleRate / 100000); + } +} + void ATVDemodGUI::leaveEvent(QEvent*) { blockApplySettings(true); @@ -469,136 +465,35 @@ void ATVDemodGUI::on_reset_clicked(bool checked) void ATVDemodGUI::on_modulation_currentIndexChanged(int index) { - // RF filters - - if (index == (int) ATVDemod::ATV_VAML) - { - ui->rfBW->setMaximum(m_objChannelizer->getInputSampleRate() / 200000); - ui->rfOppBW->setMaximum(m_objChannelizer->getInputSampleRate() / 200000); - } - else if (index == (int) ATVDemod::ATV_VAMU) - { - ui->rfBW->setMaximum(m_objChannelizer->getInputSampleRate() / 200000); - ui->rfOppBW->setMaximum(m_objChannelizer->getInputSampleRate() / 200000); - } - else - { - ui->rfBW->setMaximum(m_objChannelizer->getInputSampleRate() / 100000); - ui->rfOppBW->setMaximum(m_objChannelizer->getInputSampleRate() / 100000); - } - - // channel marker - - m_blnDoApplySettings = false; // avoid infinite recursion - - if (ui->rfFiltering->isChecked()) - { - if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAML) - { - m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - m_objChannelMarker.setSidebands(ChannelMarker::vlsb); - } - else if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAMU) - { - m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - m_objChannelMarker.setSidebands(ChannelMarker::vusb); - } - else - { - m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); - m_objChannelMarker.setSidebands(ChannelMarker::dsb); - } - } - else - { - m_objChannelMarker.setBandwidth(m_objChannelizer->getInputSampleRate()); - m_objChannelMarker.setSidebands(ChannelMarker::dsb); - - } - - m_blnDoApplySettings = true; + setRFFiltersSlidersRange(m_objATVDemod->getEffectiveSampleRate()); + setChannelMarkerBandwidth(); applyRFSettings(); } void ATVDemodGUI::on_rfBW_valueChanged(int value) { ui->rfBWText->setText(QString("%1 MHz").arg(value / 10.0, 0, 'f', 1)); - - // channel marker - - if (ui->rfFiltering->isChecked()) - { - m_blnDoApplySettings = false; // avoid infinite recursion - m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); - m_blnDoApplySettings = true; - applyRFSettings(); - } + setChannelMarkerBandwidth(); + applyRFSettings(); } void ATVDemodGUI::on_rfOppBW_valueChanged(int value) { ui->rfOppBWText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1)); - - // channel marker - - if (ui->rfFiltering->isChecked()) - { - m_blnDoApplySettings = false; // avoid infinite recursion - - if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAML) - { - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - } - else if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAMU) - { - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - } - - m_blnDoApplySettings = true; - applyRFSettings(); - } + setChannelMarkerBandwidth(); + applyRFSettings(); } void ATVDemodGUI::on_rfFiltering_toggled(bool checked) { - // channel marker - - m_blnDoApplySettings = false; // avoid infinite recursion - - if (ui->rfFiltering->isChecked()) - { - m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000); - - if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAML) - { - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - m_objChannelMarker.setSidebands(ChannelMarker::vlsb); - } - else if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAMU) - { - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - m_objChannelMarker.setSidebands(ChannelMarker::vusb); - } - else - { - m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000); - m_objChannelMarker.setSidebands(ChannelMarker::dsb); - } - } - else - { - m_objChannelMarker.setBandwidth(m_objChannelizer->getInputSampleRate()); - m_objChannelMarker.setSidebands(ChannelMarker::dsb); - } - - m_blnDoApplySettings = true; + setRFFiltersSlidersRange(m_objATVDemod->getEffectiveSampleRate()); + setChannelMarkerBandwidth(); applyRFSettings(); } void ATVDemodGUI::on_decimatorEnable_toggled(bool checked) { + setChannelMarkerBandwidth(); applyRFSettings(); } diff --git a/plugins/channelrx/demodatv/atvdemodgui.h b/plugins/channelrx/demodatv/atvdemodgui.h index 5788aba22..cb1d1f3b7 100644 --- a/plugins/channelrx/demodatv/atvdemodgui.h +++ b/plugins/channelrx/demodatv/atvdemodgui.h @@ -101,6 +101,8 @@ private: void blockApplySettings(bool blnBlock); void applySettings(); void applyRFSettings(); + void setChannelMarkerBandwidth(); + void setRFFiltersSlidersRange(int sampleRate); void leaveEvent(QEvent*); void enterEvent(QEvent*);