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

ATV Demod: effective sample rate reporting from demod to GUI

This commit is contained in:
f4exb 2017-03-18 10:04:57 +01:00
parent 4c983abd0b
commit f6cbdbe1ed
4 changed files with 96 additions and 35 deletions

View File

@ -27,6 +27,7 @@
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgConfigureATVDemod, Message)
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgConfigureRFATVDemod, Message)
MESSAGE_CLASS_DEFINITION(ATVDemod::MsgReportEffectiveSampleRate, Message)
const float ATVDemod::m_fltSecondToUs = 1000000.0f;
const int ATVDemod::m_ssbFftLen = 1024;
@ -63,7 +64,6 @@ ATVDemod::ATVDemod() :
m_intSynchroPoints=0;
m_intNumberOfLines=0;
m_intNumberOfRowsToDisplay=0;
m_intTVSampleRate = 0;
m_objMagSqAverage.resize(32, 1.0);
@ -79,7 +79,7 @@ ATVDemod::~ATVDemod()
{
}
bool ATVDemod::setATVScreen(ATVScreen *objScreen)
void ATVDemod::setATVScreen(ATVScreen *objScreen)
{
m_objRegisteredATVScreen = objScreen;
}
@ -596,20 +596,21 @@ void ATVDemod::applySettings()
|| (m_objRFConfig.m_fltRFBandwidth != m_objRFRunning.m_fltRFBandwidth))
{
m_objSettingsMutex.lock();
m_intTVSampleRate = (m_objConfig.m_intSampleRate / 1000000) * 1000000; // make sure working sample rate is a multiple of rate units
if (m_intTVSampleRate > 0)
m_objConfigPrivate.m_intTVSampleRate = (m_objConfig.m_intSampleRate / 1000000) * 1000000; // make sure working sample rate is a multiple of rate units
if (m_objConfigPrivate.m_intTVSampleRate > 0)
{
m_interpolatorDistance = (Real) m_intTVSampleRate / (Real) m_objConfig.m_intSampleRate;
m_interpolatorDistance = (Real) m_objConfigPrivate.m_intTVSampleRate / (Real) m_objConfig.m_intSampleRate;
}
else
{
m_intTVSampleRate = m_objConfig.m_intSampleRate;
m_objConfigPrivate.m_intTVSampleRate = m_objConfig.m_intSampleRate;
m_interpolatorDistance = 1.0f;
}
m_interpolatorDistanceRemain = 0;
m_interpolator.create(48, m_intTVSampleRate, m_objRFConfig.m_fltRFBandwidth / 2.2, 3.0);
m_interpolator.create(48, m_objConfigPrivate.m_intTVSampleRate, m_objRFConfig.m_fltRFBandwidth / 2.2, 3.0);
m_objSettingsMutex.unlock();
}
@ -636,8 +637,19 @@ void ATVDemod::applySettings()
m_objSettingsMutex.unlock();
}
if ((m_objConfigPrivate.m_intTVSampleRate != m_objRunningPrivate.m_intTVSampleRate)
|| (m_objConfig.m_intSampleRate != m_objRunning.m_intSampleRate)
|| (m_objRFConfig.m_blndecimatorEnable != m_objRFRunning.m_blndecimatorEnable))
{
int sampleRate = m_objRFConfig.m_blndecimatorEnable ? m_objConfigPrivate.m_intTVSampleRate : m_objConfig.m_intSampleRate;
MsgReportEffectiveSampleRate *report;
report = MsgReportEffectiveSampleRate::create(sampleRate);
getOutputMessageQueue()->push(report);
}
m_objRunning = m_objConfig;
m_objRFRunning = m_objRFConfig;
m_objRunningPrivate = m_objConfigPrivate;
}
int ATVDemod::getSampleRate()

View File

@ -96,6 +96,27 @@ public:
}
};
class MsgReportEffectiveSampleRate : public Message
{
MESSAGE_CLASS_DECLARATION
public:
int getSampleRate() const { return m_sampleRate; }
static MsgReportEffectiveSampleRate* create(int sampleRate)
{
return new MsgReportEffectiveSampleRate(sampleRate);
}
protected:
int m_sampleRate;
MsgReportEffectiveSampleRate(int sampleRate) :
Message(),
m_sampleRate(sampleRate)
{ }
};
ATVDemod();
~ATVDemod();
@ -121,11 +142,19 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
bool setATVScreen(ATVScreen *objScreen);
void setATVScreen(ATVScreen *objScreen);
int getSampleRate();
double getMagSq() const { return m_objMagSqAverage.average(); } //!< Beware this is scaled to 2^30
private:
struct ATVConfigPrivate
{
int m_intTVSampleRate;
ATVConfigPrivate() :
m_intTVSampleRate(0)
{}
};
class MsgConfigureATVDemod : public Message
{
@ -255,7 +284,6 @@ private:
MovingAverage<double> m_objMagSqAverage;
int m_intTVSampleRate;
NCO m_nco;
// Interpolator group for decimation and/or double sideband RF filtering
@ -277,6 +305,9 @@ private:
ATVRFConfig m_objRFRunning;
ATVRFConfig m_objRFConfig;
ATVConfigPrivate m_objRunningPrivate;
ATVConfigPrivate m_objConfigPrivate;
QMutex m_objSettingsMutex;
static const float m_fltSecondToUs;

View File

@ -170,7 +170,34 @@ bool ATVDemodGUI::deserialize(const QByteArray& arrData)
bool ATVDemodGUI::handleMessage(const Message& objMessage)
{
return false;
if (ATVDemod::MsgReportEffectiveSampleRate::match(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);
}
return true;
}
else
{
return false;
}
}
void ATVDemodGUI::viewChanged()
@ -181,34 +208,9 @@ void ATVDemodGUI::viewChanged()
void ATVDemodGUI::channelSampleRateChanged()
{
qDebug("ATVDemodGUI::channelSampleRateChanged");
ui->channelSampleRateText->setText(tr("%1k").arg(m_objChannelizer->getInputSampleRate()/1000.0f, 0, 'f', 0));
applySettings();
// filter sliders
if (ui->modulation->currentIndex() == (int) ATVDemod::ATV_VAML)
{
ui->rfBW->setMaximum(m_objChannelizer->getInputSampleRate() / 200000);
ui->rfOppBW->setMaximum(m_objChannelizer->getInputSampleRate() / 200000);
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)
{
ui->rfBW->setMaximum(m_objChannelizer->getInputSampleRate() / 200000);
ui->rfOppBW->setMaximum(m_objChannelizer->getInputSampleRate() / 200000);
m_objChannelMarker.setBandwidth(ui->rfBW->value()*100000);
m_objChannelMarker.setOppositeBandwidth(ui->rfOppBW->value()*100000);
m_objChannelMarker.setSidebands(ChannelMarker::vusb);
}
else
{
ui->rfBW->setMaximum(m_objChannelizer->getInputSampleRate() / 100000);
ui->rfOppBW->setMaximum(m_objChannelizer->getInputSampleRate() / 100000);
m_objChannelMarker.setSidebands(ChannelMarker::dsb);
}
// channel marker
@ -244,6 +246,19 @@ void ATVDemodGUI::channelSampleRateChanged()
applyRFSettings();
}
void ATVDemodGUI::handleSourceMessages()
{
Message* message;
while ((message = m_objATVDemod->getOutputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
delete message;
}
}
}
void ATVDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
}
@ -307,6 +322,8 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceSourceAPI *objDeviceAPI,
m_objMagSqAverage.resize(4, 1.0);
resetToDefaults(); // does applySettings()
connect(m_objATVDemod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
}
ATVDemodGUI::~ATVDemodGUI()

View File

@ -59,6 +59,7 @@ public:
private slots:
void viewChanged();
void channelSampleRateChanged();
void handleSourceMessages();
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void tick();