1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 21:01:45 -05:00

Channel analyzer NG: fixed GUI displays (mainly spectrum) when channel sample rate changes. Some code cleanup

This commit is contained in:
f4exb 2017-11-11 05:10:15 +01:00
parent e6b2d12236
commit 32e225263e
4 changed files with 65 additions and 40 deletions

View File

@ -48,7 +48,6 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(DeviceSourceAPI *deviceAPI) :
m_channelizer = new DownChannelizer(this); m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelizerInputSampleRateChanged()));
m_deviceAPI->addThreadedSink(m_threadedChannelizer); m_deviceAPI->addThreadedSink(m_threadedChannelizer);
apply(true); apply(true);
@ -118,12 +117,6 @@ void ChannelAnalyzerNG::stop()
{ {
} }
void ChannelAnalyzerNG::channelizerInputSampleRateChanged()
{
MsgReportChannelSampleRateChanged *msg = MsgReportChannelSampleRateChanged::create();
getMessageQueueToGUI()->push(msg);
}
bool ChannelAnalyzerNG::handleMessage(const Message& cmd) bool ChannelAnalyzerNG::handleMessage(const Message& cmd)
{ {
qDebug() << "ChannelAnalyzerNG::handleMessage: " << cmd.getIdentifier(); qDebug() << "ChannelAnalyzerNG::handleMessage: " << cmd.getIdentifier();
@ -140,6 +133,13 @@ bool ChannelAnalyzerNG::handleMessage(const Message& cmd)
<< " frequencyOffset: " << m_config.m_frequency; << " frequencyOffset: " << m_config.m_frequency;
apply(); apply();
if (getMessageQueueToGUI())
{
MsgReportChannelSampleRateChanged *msg = MsgReportChannelSampleRateChanged::create();
getMessageQueueToGUI()->push(msg);
}
return true; return true;
} }
else if (MsgConfigureChannelizer::match(cmd)) else if (MsgConfigureChannelizer::match(cmd))

View File

@ -145,9 +145,6 @@ public:
static const QString m_channelID; static const QString m_channelID;
private slots:
void channelizerInputSampleRateChanged();
private: private:
struct Config struct Config

View File

@ -156,12 +156,50 @@ bool ChannelAnalyzerNGGUI::deserialize(const QByteArray& data)
} }
} }
bool ChannelAnalyzerNGGUI::handleMessage(const Message& message __attribute__((unused))) bool ChannelAnalyzerNGGUI::handleMessage(const Message& message)
{ {
if (ChannelAnalyzerNG::MsgReportChannelSampleRateChanged::match(message)) if (ChannelAnalyzerNG::MsgReportChannelSampleRateChanged::match(message))
{ {
setNewFinalRate(m_spanLog2); int newRate = getRequestedChannelSampleRate() / (1<<m_spanLog2);
applySettings();
int newBW = (ui->BW->value() * 100 * m_rate) / newRate;
int newLC = (ui->lowCut->value() * 100 * m_rate) / newRate;
qDebug() << "ChannelAnalyzerNGGUI::handleMessage: MsgReportChannelSampleRateChanged:"
<< " newRate: " << newRate
<< " newBW: " << newBW
<< " newLC: " << newLC;
m_rate = newRate;
ui->BW->setValue(newBW/100);
ui->lowCut->setValue(newLC/100);
blockApplySettings(true);
setFiltersUIBoundaries();
blockApplySettings(false);
if (ui->ssb->isChecked())
{
QString s = QString::number(ui->BW->value()/10.0, 'f', 1);
ui->BWText->setText(tr("%1k").arg(s));
}
else
{
QString s = QString::number(ui->BW->value()/5.0, 'f', 1); // BW = value * 2
ui->BWText->setText(tr("%1k").arg(s));
}
QString s = QString::number(ui->lowCut->value()/10.0, 'f', 1);
ui->lowCutText->setText(tr("%1k").arg(s));
s = QString::number(m_rate/1000.0, 'f', 1);
ui->spanText->setText(tr("%1 kS/s").arg(s));
ui->glScope->setSampleRate(m_rate);
displayBandwidth(); // sets ui->glSpectrum sample rate
return true; return true;
} }
@ -183,7 +221,7 @@ void ChannelAnalyzerNGGUI::handleInputMessages()
} }
} }
void ChannelAnalyzerNGGUI::viewChanged() void ChannelAnalyzerNGGUI::channelMarkerChanged()
{ {
applySettings(); applySettings();
} }
@ -195,13 +233,6 @@ void ChannelAnalyzerNGGUI::tick()
ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.average(), 0, 'f', 1)); ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.average(), 0, 'f', 1));
} }
//void ChannelAnalyzerNGGUI::channelizerInputSampleRateChanged()
//{
// //ui->channelSampleRate->setValueRange(7, 2000U, m_channelAnalyzer->getInputSampleRate());
// setNewFinalRate(m_spanLog2);
// applySettings();
//}
void ChannelAnalyzerNGGUI::on_channelSampleRate_changed(quint64 value) void ChannelAnalyzerNGGUI::on_channelSampleRate_changed(quint64 value)
{ {
ui->channelSampleRate->setValueRange(7, 2000U, m_channelAnalyzer->getInputSampleRate()); ui->channelSampleRate->setValueRange(7, 2000U, m_channelAnalyzer->getInputSampleRate());
@ -236,7 +267,7 @@ void ChannelAnalyzerNGGUI::on_deltaFrequency_changed(qint64 value)
void ChannelAnalyzerNGGUI::on_BW_valueChanged(int value) void ChannelAnalyzerNGGUI::on_BW_valueChanged(int value)
{ {
m_channelMarker.setBandwidth(value * 100 * 2); // m_channelMarker.setBandwidth(value * 100 * 2);
if (ui->ssb->isChecked()) if (ui->ssb->isChecked())
{ {
@ -250,7 +281,7 @@ void ChannelAnalyzerNGGUI::on_BW_valueChanged(int value)
} }
displayBandwidth(); displayBandwidth();
on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100); on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100); // does apply settings
} }
int ChannelAnalyzerNGGUI::getEffectiveLowCutoff(int lowCutoff) int ChannelAnalyzerNGGUI::getEffectiveLowCutoff(int lowCutoff)
@ -280,11 +311,13 @@ int ChannelAnalyzerNGGUI::getEffectiveLowCutoff(int lowCutoff)
void ChannelAnalyzerNGGUI::on_lowCut_valueChanged(int value) void ChannelAnalyzerNGGUI::on_lowCut_valueChanged(int value)
{ {
blockApplySettings(true);
int lowCutoff = getEffectiveLowCutoff(value * 100); int lowCutoff = getEffectiveLowCutoff(value * 100);
m_channelMarker.setLowCutoff(lowCutoff); m_channelMarker.setLowCutoff(lowCutoff);
QString s = QString::number(lowCutoff/1000.0, 'f', 1); QString s = QString::number(lowCutoff/1000.0, 'f', 1);
ui->lowCutText->setText(tr("%1k").arg(s)); ui->lowCutText->setText(tr("%1k").arg(s));
ui->lowCut->setValue(lowCutoff/100); ui->lowCut->setValue(lowCutoff/100);
blockApplySettings(false);
applySettings(); applySettings();
} }
@ -398,7 +431,7 @@ ChannelAnalyzerNGGUI::ChannelAnalyzerNGGUI(PluginAPI* pluginAPI, DeviceUISet *de
m_channelMarker.setCenterFrequency(0); m_channelMarker.setCenterFrequency(0);
m_channelMarker.setVisible(true); m_channelMarker.setVisible(true);
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged())); connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
m_deviceUISet->registerRxChannelInstance(ChannelAnalyzerNG::m_channelID, this); m_deviceUISet->registerRxChannelInstance(ChannelAnalyzerNG::m_channelID, this);
m_deviceUISet->addChannelMarker(&m_channelMarker); m_deviceUISet->addChannelMarker(&m_channelMarker);
@ -448,6 +481,7 @@ bool ChannelAnalyzerNGGUI::setNewFinalRate(int spanLog2)
displayBandwidth(); displayBandwidth();
ui->glScope->setSampleRate(m_rate); ui->glScope->setSampleRate(m_rate);
ui->glSpectrum->setSampleRate(m_rate);
m_scopeVis->setSampleRate(m_rate); m_scopeVis->setSampleRate(m_rate);
return true; return true;
@ -455,6 +489,10 @@ bool ChannelAnalyzerNGGUI::setNewFinalRate(int spanLog2)
void ChannelAnalyzerNGGUI::displayBandwidth() void ChannelAnalyzerNGGUI::displayBandwidth()
{ {
blockApplySettings(true);
m_channelMarker.setBandwidth(ui->BW->value() * 100 * 2);
if (ui->ssb->isChecked()) if (ui->ssb->isChecked())
{ {
if (ui->BW->value() < 0) if (ui->BW->value() < 0)
@ -468,8 +506,9 @@ void ChannelAnalyzerNGGUI::displayBandwidth()
ui->glSpectrum->setLsbDisplay(false); ui->glSpectrum->setLsbDisplay(false);
} }
ui->glSpectrum->setCenterFrequency(m_rate/4); m_channelMarker.setLowCutoff(ui->lowCut->value()*100);
ui->glSpectrum->setSampleRate(m_rate/2); ui->glSpectrum->setSampleRate(m_rate/2);
ui->glSpectrum->setCenterFrequency(m_rate/4);
ui->glSpectrum->setSsbSpectrum(true); ui->glSpectrum->setSsbSpectrum(true);
} }
else else
@ -482,7 +521,7 @@ void ChannelAnalyzerNGGUI::displayBandwidth()
ui->glSpectrum->setSsbSpectrum(false); ui->glSpectrum->setSsbSpectrum(false);
} }
blockApplySettings(false);
} }
void ChannelAnalyzerNGGUI::setFiltersUIBoundaries() void ChannelAnalyzerNGGUI::setFiltersUIBoundaries()
@ -541,14 +580,8 @@ void ChannelAnalyzerNGGUI::applySettings()
m_channelMarker.getCenterFrequency()); m_channelMarker.getCenterFrequency());
m_channelAnalyzer->getInputMessageQueue()->push(msg); m_channelAnalyzer->getInputMessageQueue()->push(msg);
// m_channelizer->configure(m_channelizer->getInputMessageQueue(),
// //m_channelizer->getInputSampleRate(),
// getRequestedChannelSampleRate(),
// m_channelMarker.getCenterFrequency());
m_channelAnalyzer->configure(m_channelAnalyzer->getInputMessageQueue(), m_channelAnalyzer->configure(m_channelAnalyzer->getInputMessageQueue(),
//m_channelizer->getInputSampleRate(), // TODO: specify required channel sample rate sampleRate,
sampleRate, // TODO: specify required channel sample rate
ui->BW->value() * 100.0, ui->BW->value() * 100.0,
ui->lowCut->value() * 100.0, ui->lowCut->value() * 100.0,
m_spanLog2, m_spanLog2,

View File

@ -26,8 +26,6 @@
class PluginAPI; class PluginAPI;
class DeviceUISet; class DeviceUISet;
class BasebandSampleSink; class BasebandSampleSink;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class ChannelAnalyzerNG; class ChannelAnalyzerNG;
class SpectrumScopeNGComboVis; class SpectrumScopeNGComboVis;
class SpectrumVis; class SpectrumVis;
@ -56,8 +54,7 @@ public:
virtual bool handleMessage(const Message& message); virtual bool handleMessage(const Message& message);
private slots: private slots:
void viewChanged(); void channelMarkerChanged();
// void channelizerInputSampleRateChanged();
void on_deltaFrequency_changed(qint64 value); void on_deltaFrequency_changed(qint64 value);
void on_channelSampleRate_changed(quint64 value); void on_channelSampleRate_changed(quint64 value);
void on_useRationalDownsampler_toggled(bool checked); void on_useRationalDownsampler_toggled(bool checked);
@ -81,8 +78,6 @@ private:
int m_spanLog2; int m_spanLog2;
MovingAverage<double> m_channelPowerDbAvg; MovingAverage<double> m_channelPowerDbAvg;
// ThreadedBasebandSampleSink* m_threadedChannelizer;
// DownChannelizer* m_channelizer;
ChannelAnalyzerNG* m_channelAnalyzer; ChannelAnalyzerNG* m_channelAnalyzer;
SpectrumScopeNGComboVis* m_spectrumScopeComboVis; SpectrumScopeNGComboVis* m_spectrumScopeComboVis;
SpectrumVis* m_spectrumVis; SpectrumVis* m_spectrumVis;