1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

ATV demod: GUI and demod separation (2)

This commit is contained in:
f4exb 2017-11-06 23:57:59 +01:00
parent 5131fb86b1
commit f2fe5753b1
4 changed files with 91 additions and 38 deletions

View File

@ -15,26 +15,31 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "atvdemod.h"
#include <QTime>
#include <QDebug>
#include <stdio.h>
#include <complex.h>
#include "audio/audiooutput.h"
#include "dsp/dspengine.h"
#include "dsp/pidcontroller.h"
#include "dsp/downchannelizer.h"
#include "dsp/threadedbasebandsamplesink.h"
#include "device/devicesourceapi.h"
#include "atvdemod.h"
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgConfigureATVDemod, Message)
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgConfigureRFATVDemod, Message)
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgReportEffectiveSampleRate, Message)
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgReportChannelSampleRateChanged, Message)
const int ATVDemod::m_ssbFftLen = 1024;
ATVDemod::ATVDemod(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_registeredATVScreen(NULL),
m_registeredATVScreen(0),
m_intNumberSamplePerTop(0),
m_intImageIndex(0),
m_intSynchroPoints(0),
@ -80,11 +85,20 @@ ATVDemod::ATVDemod(DeviceSourceAPI *deviceAPI) :
m_objPhaseDiscri.setFMScaling(1.0f);
m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
applyStandard();
}
ATVDemod::~ATVDemod()
{
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
}
void ATVDemod::setATVScreen(ATVScreen *objScreen)
@ -450,6 +464,19 @@ bool ATVDemod::handleMessage(const Message& cmd)
return true;
}
else if (MsgConfigureChannelizer::match(cmd))
{
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
m_channelizer->getInputSampleRate(),
cfg.getCenterFrequency());
qDebug() << "ATVDemod::handleMessage: MsgConfigureChannelizer: sampleRate: " << m_channelizer->getInputSampleRate()
<< " centerFrequency: " << cfg.getCenterFrequency();
return true;
}
else if (MsgConfigureATVDemod::match(cmd))
{
MsgConfigureATVDemod& objCfg = (MsgConfigureATVDemod&) cmd;
@ -575,10 +602,13 @@ void ATVDemod::applySettings()
m_configPrivate.m_intNumberSamplePerLine = (int) (m_config.m_fltLineDuration * m_config.m_intSampleRate);
m_intNumberSamplePerTop = (int) (m_config.m_fltTopDuration * m_config.m_intSampleRate);
if (m_registeredATVScreen)
{
m_registeredATVScreen->setRenderImmediate(!(m_config.m_fltFramePerS > 25.0f));
m_registeredATVScreen->resizeATVScreen(
m_configPrivate.m_intNumberSamplePerLine - m_intNumberSamplePerLineSignals,
m_intNumberOfLines - m_intNumberOfBlackLines);
}
qDebug() << "ATVDemod::applySettings:"
<< " m_fltLineDuration: " << m_config.m_fltLineDuration
@ -632,7 +662,7 @@ void ATVDemod::applySettings()
m_rfRunning = m_rfConfig;
m_runningPrivate = m_configPrivate;
if (forwardSampleRateChange)
if (forwardSampleRateChange && getMessageQueueToGUI())
{
int sampleRate = m_rfRunning.m_blndecimatorEnable ? m_runningPrivate.m_intTVSampleRate : m_running.m_intSampleRate;
MsgReportEffectiveSampleRate *report;
@ -732,3 +762,13 @@ float ATVDemod::getRFBandwidthDivisor(ATVModulation modulation)
}
}
void ATVDemod::channelSampleRateChanged()
{
qDebug("ATVDemod::channelSampleRateChanged");
if (getMessageQueueToGUI())
{
MsgReportChannelSampleRateChanged *msg = MsgReportChannelSampleRateChanged::create(m_channelizer->getInputSampleRate());
getMessageQueueToGUI()->push(msg);
}
}

View File

@ -39,6 +39,8 @@
#include "atvscreen.h"
class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class ATVDemod : public BasebandSampleSink
{
@ -123,6 +125,26 @@ public:
}
};
class MsgConfigureChannelizer : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getCenterFrequency() const { return m_centerFrequency; }
static MsgConfigureChannelizer* create(int centerFrequency)
{
return new MsgConfigureChannelizer(centerFrequency);
}
private:
int m_centerFrequency;
MsgConfigureChannelizer(int centerFrequency) :
Message(),
m_centerFrequency(centerFrequency)
{ }
};
class MsgReportEffectiveSampleRate : public Message
{
MESSAGE_CLASS_DECLARATION
@ -205,6 +227,9 @@ public:
double getMagSq() const { return m_objMagSqAverage.average(); } //!< Beware this is scaled to 2^30
bool getBFOLocked();
private slots:
void channelSampleRateChanged();
private:
struct ATVConfigPrivate
{
@ -362,6 +387,8 @@ private:
};
DeviceSourceAPI* m_deviceAPI;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
//*************** SCOPE ***************

View File

@ -219,6 +219,18 @@ bool ATVDemodGUI::handleMessage(const Message& objMessage)
return true;
}
else if (ATVDemod::MsgReportChannelSampleRateChanged::match(objMessage))
{
ATVDemod::MsgReportChannelSampleRateChanged report = (ATVDemod::MsgReportChannelSampleRateChanged&) objMessage;
m_inputSampleRate = report.getSampleRate();
qDebug("ATVDemodGUI::handleMessage: MsgReportChannelSampleRateChanged: %d", m_inputSampleRate);
applySettings();
applyRFSettings();
return true;
}
else
{
return false;
@ -232,14 +244,6 @@ void ATVDemodGUI::viewChanged()
applyRFSettings();
}
void ATVDemodGUI::channelSampleRateChanged()
{
qDebug("ATVDemodGUI::channelSampleRateChanged");
m_inputSampleRate = m_channelizer->getInputSampleRate();
applySettings();
applyRFSettings();
}
void ATVDemodGUI::handleSourceMessages()
{
Message* message;
@ -288,14 +292,10 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet,
m_scopeVis = new ScopeVisNG(ui->glScope);
m_atvDemod = new ATVDemod(m_deviceUISet->m_deviceSourceAPI);
m_atvDemod->setScopeSink(m_scopeVis);
m_atvDemod->setMessageQueueToGUI(getInputMessageQueue());
m_atvDemod->setScopeSink(m_scopeVis);
m_atvDemod->setATVScreen(ui->screenTV);
m_channelizer = new DownChannelizer(m_atvDemod);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceUISet->m_deviceSourceAPI->addThreadedSink(m_threadedChannelizer);
ui->glScope->connectTimer(MainWindow::getInstance()->getMasterTimer());
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
@ -303,9 +303,6 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet,
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
//m_objPluginAPI->addThreadedSink(m_objThreadedChannelizer);
m_channelMarker.setColor(Qt::white);
m_channelMarker.setMovable(false);
m_channelMarker.setBandwidth(6000000);
@ -319,8 +316,6 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet,
m_deviceUISet->addChannelMarker(&m_channelMarker);
m_deviceUISet->addRollupWidget(this);
//ui->screenTV->connectTimer(m_objPluginAPI->getMainWindow()->getMasterTimer());
m_objMagSqAverage.resize(4, 1.0);
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
@ -351,9 +346,6 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet,
ATVDemodGUI::~ATVDemodGUI()
{
m_deviceUISet->removeRxChannelInstance(this);
m_deviceUISet->m_deviceSourceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_atvDemod;
delete m_scopeVis;
delete ui;
@ -370,9 +362,9 @@ void ATVDemodGUI::applySettings()
{
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
m_channelizer->getInputSampleRate(), // always use maximum available bandwidth
ATVDemod::MsgConfigureChannelizer *msgChan = ATVDemod::MsgConfigureChannelizer::create(
m_channelMarker.getCenterFrequency());
m_atvDemod->getInputMessageQueue()->push(msgChan);
m_atvDemod->configure(m_atvDemod->getInputMessageQueue(),
getNominalLineTime(ui->nbLines->currentIndex(), ui->fps->currentIndex()) + ui->lineTime->value() * m_fltLineTimeMultiplier,
@ -389,7 +381,7 @@ void ATVDemodGUI::applySettings()
ui->screenTabWidget->currentIndex());
qDebug() << "ATVDemodGUI::applySettings:"
<< " m_objChannelizer.inputSampleRate: " << m_channelizer->getInputSampleRate()
<< " m_objChannelizer.inputSampleRate: " << m_inputSampleRate
<< " m_objATVDemod.sampleRate: " << m_atvDemod->getSampleRate();
}
}
@ -431,7 +423,6 @@ void ATVDemodGUI::setChannelMarkerBandwidth()
if (ui->decimatorEnable->isChecked()) {
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor);
} else {
// m_channelMarker.setBandwidth(m_channelizer->getInputSampleRate());
m_channelMarker.setBandwidth(m_inputSampleRate);
}

View File

@ -27,8 +27,6 @@
class PluginAPI;
class DeviceUISet;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class ATVDemod;
class ScopeVisNG;
@ -60,7 +58,6 @@ public:
private slots:
void viewChanged();
void channelSampleRateChanged();
void handleSourceMessages();
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
@ -92,8 +89,6 @@ private:
PluginAPI* m_pluginAPI;
DeviceUISet* m_deviceUISet;
ChannelMarker m_channelMarker;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
ATVDemod* m_atvDemod;
bool m_blnBasicSettingsShown;