mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-01-05 15:58:50 -05:00
SigMF file sink: added spectrum display to GUI
This commit is contained in:
parent
1187726582
commit
20db7b735d
@ -5,6 +5,7 @@ set(sigmffilesink_SOURCES
|
||||
sigmffilesinkbaseband.cpp
|
||||
sigmffilesinksink.cpp
|
||||
sigmffilesinksettings.cpp
|
||||
sigmffilesinkmessages.cpp
|
||||
sigmffilesinkwebapiadapter.cpp
|
||||
sigmffilesinkplugin.cpp
|
||||
)
|
||||
@ -14,6 +15,7 @@ set(sigmffilesink_HEADERS
|
||||
sigmffilesinkbaseband.h
|
||||
sigmffilesinksink.h
|
||||
sigmffilesinksettings.h
|
||||
sigmffilesinkmessages.h
|
||||
sigmffilesinkwebapiadapter.h
|
||||
sigmffilesinkplugin.h
|
||||
)
|
||||
|
||||
@ -47,11 +47,13 @@ SigMFFileSink::SigMFFileSink(DeviceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_centerFrequency(0),
|
||||
m_frequencyOffset(0),
|
||||
m_spectrumVis(SDR_RX_SCALEF),
|
||||
m_basebandSampleRate(48000)
|
||||
{
|
||||
setObjectName(m_channelId);
|
||||
|
||||
m_basebandSink = new SigMFFileSinkBaseband();
|
||||
m_basebandSink->setSpectrumSink(&m_spectrumVis);
|
||||
m_basebandSink->moveToThread(&m_thread);
|
||||
|
||||
applySettings(m_settings, true);
|
||||
@ -92,6 +94,7 @@ void SigMFFileSink::start()
|
||||
{
|
||||
qDebug("SigMFFileSink::start");
|
||||
m_basebandSink->reset();
|
||||
m_basebandSink->setMessageQueueToGUI(getMessageQueueToGUI());
|
||||
m_basebandSink->startWork();
|
||||
m_thread.start();
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include <QNetworkRequest>
|
||||
|
||||
#include "dsp/basebandsamplesink.h"
|
||||
#include "dsp/spectrumvis.h"
|
||||
#include "channel/channelapi.h"
|
||||
|
||||
#include "sigmffilesinksettings.h"
|
||||
@ -108,6 +109,7 @@ public:
|
||||
|
||||
void getLocalDevices(std::vector<uint32_t>& indexes);
|
||||
uint32_t getNumberOfDeviceStreams() const;
|
||||
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
|
||||
void record(bool record);
|
||||
uint64_t getMsCount() const;
|
||||
uint64_t getByteCount() const;
|
||||
@ -121,6 +123,7 @@ private:
|
||||
QThread m_thread;
|
||||
SigMFFileSinkBaseband *m_basebandSink;
|
||||
SigMFFileSinkSettings m_settings;
|
||||
SpectrumVis m_spectrumVis;
|
||||
|
||||
uint64_t m_centerFrequency;
|
||||
int64_t m_frequencyOffset;
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "sigmffilesinksettings.h"
|
||||
|
||||
class DownChannelizer;
|
||||
class SpectrumVis;
|
||||
|
||||
class SigMFFileSinkBaseband : public QObject
|
||||
{
|
||||
@ -88,9 +89,11 @@ public:
|
||||
int getChannelSampleRate() const;
|
||||
void setBasebandSampleRate(int sampleRate);
|
||||
bool isRunning() const { return m_running; }
|
||||
void setSpectrumSink(SpectrumVis* spectrumSink) { m_sink.setSpectrumSink(spectrumSink); }
|
||||
uint64_t getMsCount() const { return m_sink.getMsCount(); }
|
||||
uint64_t getByteCount() const { return m_sink.getByteCount(); }
|
||||
unsigned int getNbTracks() const { return m_sink.getNbTracks(); }
|
||||
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_sink.setMessageQueueToGUI(messageQueue); }
|
||||
|
||||
private:
|
||||
SampleSinkFifo m_sampleFifo;
|
||||
|
||||
@ -27,8 +27,9 @@
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "sigmffilesinkgui.h"
|
||||
#include "sigmffilesinkmessages.h"
|
||||
#include "sigmffilesink.h"
|
||||
#include "sigmffilesinkgui.h"
|
||||
#include "ui_sigmffilesinkgui.h"
|
||||
|
||||
SigMFFileSinkGUI* SigMFFileSinkGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *channelRx)
|
||||
@ -117,6 +118,12 @@ bool SigMFFileSinkGUI::handleMessage(const Message& message)
|
||||
blockApplySettings(false);
|
||||
return true;
|
||||
}
|
||||
else if (SigMFFileSinkMessages::MsgConfigureSpectrum::match(message))
|
||||
{
|
||||
const SigMFFileSinkMessages::MsgConfigureSpectrum& cfg = (SigMFFileSinkMessages::MsgConfigureSpectrum&) message;
|
||||
ui->glSpectrum->setSampleRate(cfg.getSampleRate());
|
||||
ui->glSpectrum->setCenterFrequency(cfg.getCenterFrequency());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
@ -140,12 +147,15 @@ SigMFFileSinkGUI::SigMFFileSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISe
|
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
||||
|
||||
m_sigMFFileSink = (SigMFFileSink*) channelrx;
|
||||
m_spectrumVis = m_sigMFFileSink->getSpectrumVis();
|
||||
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
|
||||
m_sigMFFileSink->setMessageQueueToGUI(getInputMessageQueue());
|
||||
|
||||
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
||||
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||
ui->deltaFrequency->setValueRange(false, 8, -99999999, 99999999);
|
||||
ui->position->setEnabled(m_fixedPosition);
|
||||
ui->glSpectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
|
||||
|
||||
m_channelMarker.blockSignals(true);
|
||||
m_channelMarker.setColor(m_settings.m_rgbColor);
|
||||
@ -155,7 +165,7 @@ SigMFFileSinkGUI::SigMFFileSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISe
|
||||
m_channelMarker.blockSignals(false);
|
||||
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
||||
|
||||
m_settings.setChannelMarker(&m_channelMarker);
|
||||
m_settings.setSpectrumGUI(ui->glSpectrumGUI);
|
||||
|
||||
m_deviceUISet->registerRxChannelInstance(SigMFFileSink::m_channelIdURI, this);
|
||||
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
||||
@ -346,14 +356,11 @@ void SigMFFileSinkGUI::on_decimationFactor_currentIndexChanged(int index)
|
||||
applyDecimation();
|
||||
displayRate();
|
||||
displayPos();
|
||||
applySettings();
|
||||
|
||||
if (m_fixedPosition)
|
||||
{
|
||||
if (m_fixedPosition) {
|
||||
setFrequencyFromPos();
|
||||
applySettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
setPosFromFrequency();
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ class PluginAPI;
|
||||
class DeviceUISet;
|
||||
class SigMFFileSink;
|
||||
class BasebandSampleSink;
|
||||
class SpectrumVis;
|
||||
|
||||
namespace Ui {
|
||||
class SigMFFileSinkGUI;
|
||||
@ -72,6 +73,7 @@ private:
|
||||
bool m_doApplySettings;
|
||||
|
||||
SigMFFileSink* m_sigMFFileSink;
|
||||
SpectrumVis* m_spectrumVis;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
uint32_t m_tickCount;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>522</width>
|
||||
<height>102</height>
|
||||
<height>458</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@ -46,7 +46,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
@ -383,18 +383,39 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>100</y>
|
||||
<width>521</width>
|
||||
<height>351</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="SpectrumLayout">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<widget class="GLSpectrum" name="glSpectrum" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<width>0</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Liberation Mono</family>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GLSpectrumGUI" name="glSpectrumGUI" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -417,6 +438,18 @@
|
||||
<header>gui/valuedialz.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>GLSpectrum</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/glspectrum.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>GLSpectrumGUI</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/glspectrumgui.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../sdrgui/resources/res.qrc"/>
|
||||
|
||||
20
plugins/channelrx/sigmffilesink/sigmffilesinkmessages.cpp
Normal file
20
plugins/channelrx/sigmffilesink/sigmffilesinkmessages.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "sigmffilesinkmessages.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(SigMFFileSinkMessages::MsgConfigureSpectrum, Message)
|
||||
51
plugins/channelrx/sigmffilesink/sigmffilesinkmessages.h
Normal file
51
plugins/channelrx/sigmffilesink/sigmffilesinkmessages.h
Normal file
@ -0,0 +1,51 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_SIGMFFILESINKMESSAGES_H_
|
||||
#define INCLUDE_SIGMFFILESINKMESSAGES_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "util/message.h"
|
||||
|
||||
class SigMFFileSinkMessages : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
class MsgConfigureSpectrum : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
int64_t getCenterFrequency() const { return m_centerFrequency; }
|
||||
int getSampleRate() const { return m_sampleRate; }
|
||||
|
||||
static MsgConfigureSpectrum* create(int64_t centerFrequency, int sampleRate) {
|
||||
return new MsgConfigureSpectrum(centerFrequency, sampleRate);
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t m_centerFrequency;
|
||||
int m_sampleRate;
|
||||
|
||||
MsgConfigureSpectrum(int64_t centerFrequency, int sampleRate) :
|
||||
Message(),
|
||||
m_centerFrequency(centerFrequency),
|
||||
m_sampleRate(sampleRate)
|
||||
{ }
|
||||
};
|
||||
};
|
||||
|
||||
#endif // INCLUDE_SIGMFFILESINKMESSAGES_H_
|
||||
@ -35,7 +35,7 @@ void SigMFFileSinkSettings::resetToDefaults()
|
||||
m_rgbColor = QColor(140, 4, 4).rgb();
|
||||
m_title = "SigMF File Sink";
|
||||
m_log2Decim = 0;
|
||||
m_channelMarker = nullptr;
|
||||
m_spectrumGUI = nullptr;
|
||||
m_streamIndex = 0;
|
||||
m_useReverseAPI = false;
|
||||
m_reverseAPIAddress = "127.0.0.1";
|
||||
@ -60,6 +60,10 @@ QByteArray SigMFFileSinkSettings::serialize() const
|
||||
s.writeU32(11, m_reverseAPIChannelIndex);
|
||||
s.writeU32(12, m_log2Decim);
|
||||
|
||||
if (m_spectrumGUI) {
|
||||
s.writeBlob(13, m_spectrumGUI->serialize());
|
||||
}
|
||||
|
||||
return s.final();
|
||||
}
|
||||
|
||||
@ -77,6 +81,7 @@ bool SigMFFileSinkSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
uint32_t tmp;
|
||||
QString strtmp;
|
||||
QByteArray bytetmp;
|
||||
|
||||
d.readS32(1, &m_inputFrequencyOffset, 0);
|
||||
d.readBool(2, &m_ncoMode, false);
|
||||
@ -101,6 +106,12 @@ bool SigMFFileSinkSettings::deserialize(const QByteArray& data)
|
||||
d.readU32(12, &tmp, 0);
|
||||
m_log2Decim = tmp > 6 ? 6 : tmp;
|
||||
|
||||
if (m_spectrumGUI)
|
||||
{
|
||||
d.readBlob(13, &bytetmp);
|
||||
m_spectrumGUI->deserialize(bytetmp);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
@ -38,11 +38,11 @@ struct SigMFFileSinkSettings
|
||||
uint16_t m_reverseAPIDeviceIndex;
|
||||
uint16_t m_reverseAPIChannelIndex;
|
||||
|
||||
Serializable *m_channelMarker;
|
||||
Serializable *m_spectrumGUI;
|
||||
|
||||
SigMFFileSinkSettings();
|
||||
void resetToDefaults();
|
||||
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
|
||||
void setSpectrumGUI(Serializable *spectrumGUI) { m_spectrumGUI = spectrumGUI; }
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
|
||||
|
||||
@ -19,10 +19,14 @@
|
||||
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/sigmffilerecord.h"
|
||||
#include "dsp/spectrumvis.h"
|
||||
|
||||
#include "sigmffilesinkmessages.h"
|
||||
#include "sigmffilesinksink.h"
|
||||
|
||||
SigMFFileSinkSink::SigMFFileSinkSink() :
|
||||
m_spectrumSink(nullptr),
|
||||
m_msgQueueToGUI(nullptr),
|
||||
m_recordEnabled(false),
|
||||
m_record(false),
|
||||
m_msCount(0),
|
||||
@ -81,6 +85,10 @@ void SigMFFileSinkSink::feed(const SampleVector::const_iterator& begin, const Sa
|
||||
}
|
||||
}
|
||||
|
||||
if (m_spectrumSink) {
|
||||
m_spectrumSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), false);
|
||||
}
|
||||
|
||||
m_sampleBuffer.clear();
|
||||
}
|
||||
|
||||
@ -107,7 +115,7 @@ void SigMFFileSinkSink::applyChannelSettings(
|
||||
if ((m_channelSampleRate != channelSampleRate)
|
||||
|| (m_sinkSampleRate != sinkSampleRate) || force)
|
||||
{
|
||||
m_interpolator.create(16, channelSampleRate, channelSampleRate / 2.2f);
|
||||
m_interpolator.create(16, channelSampleRate, channelSampleRate / 2.0f);
|
||||
m_interpolatorDistanceRemain = 0;
|
||||
m_interpolatorDistance = (Real) channelSampleRate / (Real) sinkSampleRate;
|
||||
}
|
||||
@ -116,8 +124,17 @@ void SigMFFileSinkSink::applyChannelSettings(
|
||||
|| (m_channelFrequencyOffset != channelFrequencyOffset)
|
||||
|| (m_sinkSampleRate != sinkSampleRate) || force)
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(sinkSampleRate, centerFrequency + m_settings.m_inputFrequencyOffset);
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(sinkSampleRate, centerFrequency);
|
||||
DSPSignalNotification *notifToSpectrum = new DSPSignalNotification(*notif);
|
||||
m_fileSink.getInputMessageQueue()->push(notif);
|
||||
m_spectrumSink->getInputMessageQueue()->push(notifToSpectrum);
|
||||
|
||||
if (m_msgQueueToGUI)
|
||||
{
|
||||
SigMFFileSinkMessages::MsgConfigureSpectrum *msg = SigMFFileSinkMessages::MsgConfigureSpectrum::create(
|
||||
centerFrequency, sinkSampleRate);
|
||||
m_msgQueueToGUI->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
m_channelSampleRate = channelSampleRate;
|
||||
@ -129,8 +146,6 @@ void SigMFFileSinkSink::applyChannelSettings(
|
||||
void SigMFFileSinkSink::applySettings(const SigMFFileSinkSettings& settings, bool force)
|
||||
{
|
||||
qDebug() << "SigMFFileSinkSink::applySettings:"
|
||||
<< "m_log2Decim:" << settings.m_log2Decim
|
||||
<< "m_inputFrequencyOffset:" << settings.m_inputFrequencyOffset
|
||||
<< "m_fileRecordName: " << settings.m_fileRecordName
|
||||
<< "force: " << force;
|
||||
|
||||
@ -152,11 +167,5 @@ void SigMFFileSinkSink::applySettings(const SigMFFileSinkSettings& settings, boo
|
||||
}
|
||||
}
|
||||
|
||||
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force)
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_sinkSampleRate, m_centerFrequency + m_settings.m_inputFrequencyOffset);
|
||||
m_fileSink.getInputMessageQueue()->push(notif);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "sigmffilesinksettings.h"
|
||||
|
||||
class FileRecordInterface;
|
||||
class SpectrumVis;
|
||||
|
||||
class SigMFFileSinkSink : public ChannelSampleSink {
|
||||
public:
|
||||
@ -35,6 +36,7 @@ public:
|
||||
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
|
||||
|
||||
SigMFFileRecord *getFileSink() { return &m_fileSink; }
|
||||
void setSpectrumSink(SpectrumVis* spectrumSink) { m_spectrumSink = spectrumSink; }
|
||||
void startRecording();
|
||||
void stopRecording();
|
||||
void setDeviceHwId(const QString& hwId) { m_deviceHwId = hwId; }
|
||||
@ -49,6 +51,7 @@ public:
|
||||
uint64_t getMsCount() const { return m_msCount; }
|
||||
uint64_t getByteCount() const { return m_byteCount; }
|
||||
unsigned int getNbTracks() const { return m_fileSink.getNbCaptures(); }
|
||||
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_msgQueueToGUI = messageQueue; }
|
||||
|
||||
private:
|
||||
int m_channelSampleRate;
|
||||
@ -62,6 +65,8 @@ private:
|
||||
SampleVector m_sampleBuffer;
|
||||
SigMFFileSinkSettings m_settings;
|
||||
SigMFFileRecord m_fileSink;
|
||||
SpectrumVis* m_spectrumSink;
|
||||
MessageQueue *m_msgQueueToGUI;
|
||||
bool m_recordEnabled;
|
||||
bool m_record;
|
||||
QString m_deviceHwId;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user