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

pull/962/head
f4exb 2021-07-10 22:41:24 +02:00
rodzic 8725fa743a
commit 3a3dc0d8c0
4 zmienionych plików z 26 dodań i 4 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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