diff --git a/plugins/channelrx/demodatv/atvdemod.cpp b/plugins/channelrx/demodatv/atvdemod.cpp index f4f4540e7..8fbf1a4c6 100644 --- a/plugins/channelrx/demodatv/atvdemod.cpp +++ b/plugins/channelrx/demodatv/atvdemod.cpp @@ -29,6 +29,7 @@ MESSAGE_CLASS_DEFINITION(ATVDemod::MsgConfigureATVDemod, Message) MESSAGE_CLASS_DEFINITION(ATVDemod::MsgConfigureRFATVDemod, Message) const float ATVDemod::m_fltSecondToUs = 1000000.0f; +const int ATVDemod::m_ssbFftLen = 1024; ATVDemod::ATVDemod() : m_objSettingsMutex(QMutex::NonRecursive), @@ -48,7 +49,12 @@ ATVDemod::ATVDemod() : m_fltAmpMax(2000000000.0f), m_fltAmpDelta(1.0), m_fltAmpLineAverage(0.0f), - m_intNumberSamplePerTop(0) + m_intNumberSamplePerTop(0), + m_interpolatorDistanceRemain(0.0f), + m_interpolatorDistance(1.0f), + m_DSBFilter(0), + m_DSBFilterBuffer(0), + m_DSBFilterBufferIndex(0) { setObjectName("ATVDemod"); @@ -60,9 +66,12 @@ ATVDemod::ATVDemod() : m_objMagSqAverage.resize(32, 1.0); + m_DSBFilter = new fftfilt((2.0f * m_objRFConfig.m_fltRFBandwidth) / 1000000, 2 * m_ssbFftLen); // arbitrary 1 MS/s sample rate + m_DSBFilterBuffer = new Complex[m_ssbFftLen]; + memset(m_DSBFilterBuffer, 0, sizeof(Complex)*(m_ssbFftLen)); + memset((void*)m_fltBufferI,0,6*sizeof(float)); memset((void*)m_fltBufferQ,0,6*sizeof(float)); - } ATVDemod::~ATVDemod() @@ -102,13 +111,15 @@ void ATVDemod::configureRF( ATVModulation enmModulation, float fltRFBandwidth, float fltRFOppBandwidth, - bool blnFFTFiltering) + bool blnFFTFiltering, + bool blnDecimatorEnable) { Message* msgCmd = MsgConfigureRFATVDemod::create( enmModulation, fltRFBandwidth, fltRFOppBandwidth, - blnFFTFiltering); + blnFFTFiltering, + blnDecimatorEnable); objMessageQueue->push(msgCmd); } @@ -521,7 +532,8 @@ bool ATVDemod::handleMessage(const Message& cmd) << " m_enmModulation" << m_objRFConfig.m_enmModulation << " m_fltRFBandwidth" << m_objRFConfig.m_fltRFBandwidth << " m_fltRFOppBandwidth" << m_objRFConfig.m_fltRFOppBandwidth - << " m_blnFFTFiltering" << m_objRFConfig.m_blnFFTFiltering; + << " m_blnFFTFiltering" << m_objRFConfig.m_blnFFTFiltering + << " m_blnDecimatorEnable" << m_objRFConfig.m_blndecimatorEnable; applySettings(); diff --git a/plugins/channelrx/demodatv/atvdemod.h b/plugins/channelrx/demodatv/atvdemod.h index 60d785f79..19deb84a6 100644 --- a/plugins/channelrx/demodatv/atvdemod.h +++ b/plugins/channelrx/demodatv/atvdemod.h @@ -18,16 +18,18 @@ #ifndef INCLUDE_ATVDEMOD_H #define INCLUDE_ATVDEMOD_H -#include -#include -#include -#include #include #include #include + +#include "dsp/basebandsamplesink.h" +#include "dsp/devicesamplesource.h" +#include "dsp/dspcommands.h" +#include "dsp/downchannelizer.h" #include "dsp/nco.h" #include "dsp/interpolator.h" #include "dsp/movingaverage.h" +#include "dsp/fftfilt.h" #include "dsp/agc.h" #include "audio/audiofifo.h" #include "util/message.h" @@ -41,11 +43,11 @@ class ATVDemod : public BasebandSampleSink public: enum ATVModulation { - ATV_FM1, - ATV_FM2, - ATV_AM, - ATV_VAMU, - ATV_VAML + ATV_FM1, //!< Classical frequency modulation with discriminator #1 + ATV_FM2, //!< Classical frequency modulation with discriminator #2 + ATV_AM, //!< Classical amplitude modulation + ATV_VAMU, //!< AM with vestigial lower side band (main signal is in the upper side) + ATV_VAML //!< AM with vestigial upper side band (main signal is in the lower side) }; struct ATVConfig @@ -80,12 +82,14 @@ public: float m_fltRFBandwidth; float m_fltRFOppBandwidth; bool m_blnFFTFiltering; + bool m_blndecimatorEnable; ATVRFConfig() : m_enmModulation(ATV_FM1), m_fltRFBandwidth(0), m_fltRFOppBandwidth(0), - m_blnFFTFiltering(false) + m_blnFFTFiltering(false), + m_blndecimatorEnable(false) { } }; @@ -107,7 +111,8 @@ public: ATVModulation enmModulation, float fltRFBandwidth, float fltRFOppBandwidth, - bool blnFFTFiltering); + bool blnFFTFiltering, + bool blndecimatorEnable); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void start(); @@ -180,13 +185,15 @@ private: ATVModulation enmModulation, float fltRFBandwidth, float fltRFOppBandwidth, - bool blnFFTFiltering) + bool blnFFTFiltering, + bool blndecimatorEnable) { return new MsgConfigureRFATVDemod( enmModulation, fltRFBandwidth, fltRFOppBandwidth, - blnFFTFiltering); + blnFFTFiltering, + blndecimatorEnable); } ATVRFConfig m_objMsgConfig; @@ -196,7 +203,8 @@ private: ATVModulation enmModulation, float fltRFBandwidth, float fltRFOppBandwidth, - bool blnFFTFiltering) : + bool blnFFTFiltering, + bool blndecimatorEnable) : Message() { m_objMsgConfig.m_enmModulation = enmModulation; @@ -244,6 +252,17 @@ private: MovingAverage m_objMagSqAverage; + // Interpolator group for decimation and/or double sideband RF filtering + Interpolator m_interpolator; + Real m_interpolatorDistance; + Real m_interpolatorDistanceRemain; + + // Used for vestigial SSB with asymmetrical filtering (needs double sideband scheme) + fftfilt* m_DSBFilter; + Complex* m_DSBFilterBuffer; + int m_DSBFilterBufferIndex; + static const int m_ssbFftLen; + //QElapsedTimer m_objTimer; ATVConfig m_objRunning; diff --git a/plugins/channelrx/demodatv/atvdemodgui.cpp b/plugins/channelrx/demodatv/atvdemodgui.cpp index a074590f5..b8b640710 100644 --- a/plugins/channelrx/demodatv/atvdemodgui.cpp +++ b/plugins/channelrx/demodatv/atvdemodgui.cpp @@ -361,7 +361,8 @@ void ATVDemodGUI::applyRFSettings() (ATVDemod::ATVModulation) ui->modulation->currentIndex(), ui->rfBW->value() * 100000.0f, ui->rfOppBW->value() * 100000.0f, - ui->rfFiltering->isChecked()); + ui->rfFiltering->isChecked(), + ui->decimator->isChecked()); } } @@ -577,3 +578,9 @@ void ATVDemodGUI::on_rfFiltering_toggled(bool checked) m_blnDoApplySettings = true; applyRFSettings(); } + +void ATVDemodGUI::on_decimator_toggled(bool checked) +{ + applyRFSettings(); +} + diff --git a/plugins/channelrx/demodatv/atvdemodgui.h b/plugins/channelrx/demodatv/atvdemodgui.h index 8fcf2894b..966535415 100644 --- a/plugins/channelrx/demodatv/atvdemodgui.h +++ b/plugins/channelrx/demodatv/atvdemodgui.h @@ -75,6 +75,7 @@ private slots: void on_rfBW_valueChanged(int value); void on_rfOppBW_valueChanged(int value); void on_rfFiltering_toggled(bool checked); + void on_decimator_toggled(bool checked); private: Ui::ATVDemodGUI* ui; diff --git a/plugins/channelrx/demodatv/atvdemodgui.ui b/plugins/channelrx/demodatv/atvdemodgui.ui index 195c69767..5b867186c 100644 --- a/plugins/channelrx/demodatv/atvdemodgui.ui +++ b/plugins/channelrx/demodatv/atvdemodgui.ui @@ -99,9 +99,16 @@ - - - Qt::Vertical + + + + + + + :/arrow_down.png:/arrow_down.png + + + true