1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-12 19:36:10 -05:00

ATV Demod: implemented FFT filter and interpolator (for decimation and DSB filtering)

This commit is contained in:
f4exb 2017-03-17 11:46:38 +01:00
parent f3e3549773
commit aa566f0910
5 changed files with 69 additions and 23 deletions

View File

@ -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();

View File

@ -18,16 +18,18 @@
#ifndef INCLUDE_ATVDEMOD_H
#define INCLUDE_ATVDEMOD_H
#include <dsp/basebandsamplesink.h>
#include <dsp/devicesamplesource.h>
#include <dsp/dspcommands.h>
#include <dsp/downchannelizer.h>
#include <QMutex>
#include <QElapsedTimer>
#include <vector>
#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<double> 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;

View File

@ -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();
}

View File

@ -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;

View File

@ -99,9 +99,16 @@
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="ButtonSwitch" name="decimator">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/arrow_down.png</normaloff>:/arrow_down.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>