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

Channel Analyzer / Scope: fixed sample rate handling. Fixes #956

This commit is contained in:
f4exb 2021-07-10 22:41:24 +02:00
parent 8725fa743a
commit 3a3dc0d8c0
4 changed files with 26 additions and 4 deletions

View File

@ -23,6 +23,7 @@
#include "device/deviceapi.h"
#include "dsp/dspcommands.h"
#include "dsp/devicesamplesource.h"
#include "chanalyzer.h"
MESSAGE_CLASS_DEFINITION(ChannelAnalyzer::MsgConfigureChannelAnalyzer, Message)
@ -38,7 +39,7 @@ ChannelAnalyzer::ChannelAnalyzer(DeviceAPI *deviceAPI) :
{
qDebug("ChannelAnalyzer::ChannelAnalyzer");
setObjectName(m_channelId);
getChannelSampleRate();
m_basebandSink = new ChannelAnalyzerBaseband();
m_basebandSink->moveToThread(&m_thread);
@ -62,6 +63,18 @@ ChannelAnalyzer::~ChannelAnalyzer()
qDebug("ChannelAnalyzer::~ChannelAnalyzer: done");
}
int ChannelAnalyzer::getChannelSampleRate()
{
DeviceSampleSource *source = m_deviceAPI->getSampleSource();
if (source) {
m_basebandSampleRate = source->getSampleRate();
}
qDebug("ChannelAnalyzer::getChannelSampleRate: %d", m_basebandSampleRate);
return m_basebandSampleRate;
}
void ChannelAnalyzer::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
{
(void) positiveOnly;
@ -82,6 +95,12 @@ void ChannelAnalyzer::start()
ChannelAnalyzerBaseband::MsgConfigureChannelAnalyzerBaseband *msg =
ChannelAnalyzerBaseband::MsgConfigureChannelAnalyzerBaseband::create(m_settings, true);
m_basebandSink->getInputMessageQueue()->push(msg);
if (getMessageQueueToGUI())
{
DSPSignalNotification *notifToGUI = new DSPSignalNotification(m_basebandSampleRate, m_centerFrequency);
getMessageQueueToGUI()->push(notifToGUI);
}
}
void ChannelAnalyzer::stop()

View File

@ -63,8 +63,7 @@ public:
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
ScopeVis *getScopeVis() { return &m_scopeVis; }
void setScopeVis(ScopeVis *scopeVis) { m_basebandSink->setScopeVis(scopeVis); }
int getChannelSampleRate() const { return m_basebandSink->getChannelSampleRate(); }
int getChannelSampleRate();
int getDecimation() const { return 1<<m_settings.m_log2Decim; }
double getMagSq() const { return m_basebandSink->getMagSq(); }
double getMagSqAvg() const { return m_basebandSink->getMagSqAvg(); }

View File

@ -231,6 +231,7 @@ bool ChannelAnalyzerGUI::handleMessage(const Message& message)
{
DSPSignalNotification& cmd = (DSPSignalNotification&) message;
m_basebandSampleRate = cmd.getSampleRate();
qDebug("ChannelAnalyzerGUI::handleMessage: DSPSignalNotification: m_basebandSampleRate: %d", m_basebandSampleRate);
setSinkSampleRate();
}
@ -470,6 +471,8 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_channelAnalyzer = (ChannelAnalyzer*) rxChannel;
m_basebandSampleRate = m_channelAnalyzer->getChannelSampleRate();
qDebug("ChannelAnalyzerGUI::ChannelAnalyzerGUI: m_basebandSampleRate: %d", m_basebandSampleRate);
m_spectrumVis = m_channelAnalyzer->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_scopeVis = m_channelAnalyzer->getScopeVis();
@ -557,6 +560,7 @@ void ChannelAnalyzerGUI::setSinkSampleRate()
ui->sinkSampleRateText->setText(tr("%1 kS/s").arg(s));
m_scopeVis->setLiveRate(sinkSampleRate == 0 ? 48000 : sinkSampleRate);
ui->scopeGUI->setSampleRate(sinkSampleRate == 0 ? 48000 : sinkSampleRate);
}
void ChannelAnalyzerGUI::setFiltersUIBoundaries()

View File

@ -130,7 +130,7 @@ void GLScopeGUI::setBuddies(MessageQueue* messageQueue, ScopeVis* scopeVis, GLSc
void GLScopeGUI::setSampleRate(int sampleRate)
{
m_sampleRate = sampleRate;
onScopeSampleRateChanged(sampleRate);
}
void GLScopeGUI::onScopeSampleRateChanged(int sampleRate)