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

Websocket spectrum: updated plugins

This commit is contained in:
f4exb 2020-05-05 03:24:10 +02:00
parent b1bd7f8409
commit c6083b339f
12 changed files with 116 additions and 6 deletions

View File

@ -101,6 +101,11 @@ void BFMDemod::start()
m_basebandSink->reset();
m_thread->start();
GLSpectrumSettings spectrumSettings = m_spectrumVis.getSettings();
spectrumSettings.m_ssb = true;
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
m_spectrumVis.getInputMessageQueue()->push(msg);
}
void BFMDemod::stop()

View File

@ -20,6 +20,7 @@
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "dsp/downchannelizer.h"
#include "dsp/spectrumvis.h"
#include "bfmdemodreport.h"
#include "bfmdemodbaseband.h"
@ -28,7 +29,8 @@ MESSAGE_CLASS_DEFINITION(BFMDemodBaseband::MsgConfigureBFMDemodBaseband, Message
BFMDemodBaseband::BFMDemodBaseband() :
m_mutex(QMutex::Recursive),
m_messageQueueToGUI(nullptr)
m_messageQueueToGUI(nullptr),
m_spectrumVis(nullptr)
{
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000));
m_channelizer = new DownChannelizer(&m_sink);
@ -132,6 +134,12 @@ bool BFMDemodBaseband::handleMessage(const Message& cmd)
getMessageQueueToGUI()->push(msg);
}
if (m_spectrumVis)
{
DSPSignalNotification *msg = new DSPSignalNotification(m_channelizer->getChannelSampleRate(), 0);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
return true;
}
else
@ -154,6 +162,12 @@ void BFMDemodBaseband::applySettings(const BFMDemodSettings& settings, bool forc
BFMDemodReport::MsgReportChannelSampleRateChanged *msg = BFMDemodReport::MsgReportChannelSampleRateChanged::create(m_channelizer->getChannelSampleRate());
getMessageQueueToGUI()->push(msg);
}
if (m_spectrumVis)
{
DSPSignalNotification *msg = new DSPSignalNotification(m_channelizer->getChannelSampleRate(), 0);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
@ -191,4 +205,10 @@ void BFMDemodBaseband::setBasebandSampleRate(int sampleRate)
BFMDemodReport::MsgReportChannelSampleRateChanged *msg = BFMDemodReport::MsgReportChannelSampleRateChanged::create(m_channelizer->getChannelSampleRate());
getMessageQueueToGUI()->push(msg);
}
if (m_spectrumVis)
{
DSPSignalNotification *msg = new DSPSignalNotification(m_channelizer->getChannelSampleRate(), 0);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
}

View File

@ -28,6 +28,7 @@
#include "bfmdemodsink.h"
class DownChannelizer;
class SpectrumVis;
class BFMDemodBaseband : public QObject
{
@ -63,7 +64,7 @@ public:
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
int getChannelSampleRate() const;
void setBasebandSampleRate(int sampleRate);
void setSpectrumSink(BasebandSampleSink* spectrumSink) { m_sink.setSpectrumSink(spectrumSink); }
void setSpectrumSink(SpectrumVis* spectrumSink) { m_spectrumVis = spectrumSink; m_sink.setSpectrumSink((BasebandSampleSink*) spectrumSink); }
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_messageQueueToGUI = messageQueue; }
int getAudioSampleRate() const { return m_sink.getAudioSampleRate(); }
@ -87,6 +88,7 @@ private:
BFMDemodSettings m_settings;
QMutex m_mutex;
MessageQueue *m_messageQueueToGUI;
SpectrumVis *m_spectrumVis;
MessageQueue *getMessageQueueToGUI() { return m_messageQueueToGUI; }

View File

@ -94,6 +94,11 @@ void FreeDVDemod::start()
m_basebandSink->reset();
m_thread->start();
GLSpectrumSettings spectrumSettings = m_spectrumVis.getSettings();
spectrumSettings.m_ssb = true;
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
m_spectrumVis.getInputMessageQueue()->push(msg);
}
void FreeDVDemod::stop()
@ -195,6 +200,15 @@ void FreeDVDemod::applySettings(const FreeDVDemodSettings& settings, bool force)
reverseAPIKeys.append("streamIndex");
}
if ((settings.m_freeDVMode != m_settings.m_freeDVMode)
|| (settings.m_spanLog2 != m_settings.m_spanLog2) || force)
{
DSPSignalNotification *msg = new DSPSignalNotification(
FreeDVDemodSettings::getModSampleRate(settings.m_freeDVMode)/(1<<settings.m_spanLog2),
0);
m_spectrumVis.getInputMessageQueue()->push(msg);
}
FreeDVDemodBaseband::MsgConfigureFreeDVDemodBaseband *msg = FreeDVDemodBaseband::MsgConfigureFreeDVDemodBaseband::create(settings, force);
m_basebandSink->getInputMessageQueue()->push(msg);

View File

@ -224,6 +224,17 @@ void SSBDemod::applySettings(const SSBDemodSettings& settings, bool force)
reverseAPIKeys.append("streamIndex");
}
if ((settings.m_dsb != m_settings.m_dsb)
|| (settings.m_rfBandwidth != m_settings.m_rfBandwidth)
|| (settings.m_lowCutoff != m_settings.m_lowCutoff) || force)
{
GLSpectrumSettings spectrumSettings = m_spectrumVis.getSettings();
spectrumSettings.m_ssb = !settings.m_dsb;
spectrumSettings.m_usb = (settings.m_lowCutoff < settings.m_rfBandwidth);
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
m_spectrumVis.getInputMessageQueue()->push(msg);
}
SSBDemodBaseband::MsgConfigureSSBDemodBaseband *msg = SSBDemodBaseband::MsgConfigureSSBDemodBaseband::create(settings, force);
m_basebandSink->getInputMessageQueue()->push(msg);

View File

@ -20,6 +20,7 @@
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "dsp/downchannelizer.h"
#include "dsp/spectrumvis.h"
#include "ssbdemodbaseband.h"
@ -27,6 +28,7 @@ MESSAGE_CLASS_DEFINITION(SSBDemodBaseband::MsgConfigureSSBDemodBaseband, Message
SSBDemodBaseband::SSBDemodBaseband() :
m_messageQueueToGUI(nullptr),
m_spectrumVis(nullptr),
m_mutex(QMutex::Recursive)
{
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000));
@ -144,6 +146,15 @@ void SSBDemodBaseband::applySettings(const SSBDemodSettings& settings, bool forc
m_sink.applyAudioSampleRate(m_audioSampleRate); // reapply in case of channel sample rate change
}
if ((settings.m_spanLog2 != m_settings.m_spanLog2) || force)
{
if (m_spectrumVis)
{
DSPSignalNotification *msg = new DSPSignalNotification(m_audioSampleRate/(1<<settings.m_spanLog2), 0);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
{
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
@ -163,6 +174,12 @@ void SSBDemodBaseband::applySettings(const SSBDemodSettings& settings, bool forc
DSPConfigureAudio *msg = new DSPConfigureAudio((int) audioSampleRate, DSPConfigureAudio::AudioOutput);
getMessageQueueToGUI()->push(msg);
}
if (m_spectrumVis)
{
DSPSignalNotification *msg = new DSPSignalNotification(m_audioSampleRate/(1<<m_settings.m_spanLog2), 0);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
}
}

View File

@ -62,7 +62,7 @@ public:
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
int getChannelSampleRate() const;
void setSpectrumSink(BasebandSampleSink* spectrumSink) { m_sink.setSpectrumSink(spectrumSink); }
void setSpectrumSink(SpectrumVis* spectrumSink) { m_spectrumVis = spectrumSink; m_sink.setSpectrumSink(spectrumSink); }
double getMagSq() const { return m_sink.getMagSq(); }
void getMagSqLevels(double& avg, double& peak, int& nbSamples) { m_sink.getMagSqLevels(avg, peak, nbSamples); }
unsigned int getAudioSampleRate() const { return m_audioSampleRate; }
@ -78,6 +78,7 @@ private:
SSBDemodSettings m_settings;
unsigned int m_audioSampleRate;
MessageQueue *m_messageQueueToGUI;
SpectrumVis *m_spectrumVis;
QMutex m_mutex;
bool handleMessage(const Message& cmd);

View File

@ -92,6 +92,11 @@ void FreeDVMod::start()
qDebug("FreeDVMod::start");
m_basebandSource->reset();
m_thread->start();
GLSpectrumSettings spectrumSettings = m_spectrumVis.getSettings();
spectrumSettings.m_ssb = true;
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
m_spectrumVis.getInputMessageQueue()->push(msg);
}
void FreeDVMod::stop()
@ -277,6 +282,15 @@ void FreeDVMod::applySettings(const FreeDVModSettings& settings, bool force)
reverseAPIKeys.append("streamIndex");
}
if ((settings.m_freeDVMode != m_settings.m_freeDVMode)
|| (settings.m_spanLog2 != m_settings.m_spanLog2) || force)
{
DSPSignalNotification *msg = new DSPSignalNotification(
FreeDVModSettings::getModSampleRate(settings.m_freeDVMode)/(1<<settings.m_spanLog2),
0);
m_spectrumVis.getInputMessageQueue()->push(msg);
}
FreeDVModBaseband::MsgConfigureFreeDVModBaseband *msg = FreeDVModBaseband::MsgConfigureFreeDVModBaseband::create(settings, force);
m_basebandSource->getInputMessageQueue()->push(msg);

View File

@ -294,6 +294,16 @@ void SSBMod::applySettings(const SSBModSettings& settings, bool force)
reverseAPIKeys.append("streamIndex");
}
if ((settings.m_dsb != m_settings.m_dsb)
|| (settings.m_usb != m_settings.m_usb) || force)
{
GLSpectrumSettings spectrumSettings = m_spectrumVis.getSettings();
spectrumSettings.m_ssb = !settings.m_dsb;
spectrumSettings.m_usb = settings.m_usb;
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
m_spectrumVis.getInputMessageQueue()->push(msg);
}
SSBModBaseband::MsgConfigureSSBModBaseband *msg = SSBModBaseband::MsgConfigureSSBModBaseband::create(settings, force);
m_basebandSource->getInputMessageQueue()->push(msg);

View File

@ -20,6 +20,7 @@
#include "dsp/upchannelizer.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "dsp/spectrumvis.h"
#include "ssbmodbaseband.h"
@ -188,6 +189,12 @@ void SSBModBaseband::applySettings(const SSBModSettings& settings, bool force)
m_source.applyAudioSampleRate(m_source.getAudioSampleRate()); // reapply in case of channel sample rate change
}
if ((settings.m_spanLog2 != m_settings.m_spanLog2) || force)
{
DSPSignalNotification *msg = new DSPSignalNotification(getAudioSampleRate()/(1<<settings.m_spanLog2), 0);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
{
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
@ -201,6 +208,8 @@ void SSBModBaseband::applySettings(const SSBModSettings& settings, bool force)
m_channelizer->setChannelization(audioSampleRate, m_settings.m_inputFrequencyOffset);
m_source.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_source.applyAudioSampleRate(audioSampleRate);
DSPSignalNotification *msg = new DSPSignalNotification(getAudioSampleRate()/(1<<m_settings.m_spanLog2), 0);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
}
@ -224,4 +233,4 @@ void SSBModBaseband::applySettings(const SSBModSettings& settings, bool force)
int SSBModBaseband::getChannelSampleRate() const
{
return m_channelizer->getChannelSampleRate();
}
}

View File

@ -29,6 +29,7 @@
class UpChannelizer;
class BasebandSampleSink;
class SpectrumVis;
class SSBModBaseband : public QObject
{
@ -70,7 +71,7 @@ public:
void setInputFileStream(std::ifstream *ifstream) { m_source.setInputFileStream(ifstream); }
AudioFifo *getAudioFifo() { return m_source.getAudioFifo(); }
AudioFifo *getFeedbackAudioFifo() { return m_source.getFeedbackAudioFifo(); }
void setSpectrumSink(BasebandSampleSink *sampleSink) { m_source.setSpectrumSink(sampleSink); }
void setSpectrumSink(SpectrumVis *sampleSink) { m_spectrumVis = sampleSink; m_source.setSpectrumSink((BasebandSampleSink *) sampleSink); }
signals:
/**
@ -87,6 +88,7 @@ private:
SSBModSource m_source;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
SSBModSettings m_settings;
SpectrumVis *m_spectrumVis;
QMutex m_mutex;
void processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd);

View File

@ -175,9 +175,14 @@ void UDPSource::applySettings(const UDPSourceSettings& settings, bool force)
if ((settings.m_sampleFormat != m_settings.m_sampleFormat) || force) {
reverseAPIKeys.append("sampleFormat");
}
if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force) {
if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force)
{
reverseAPIKeys.append("inputSampleRate");
DSPSignalNotification *msg = new DSPSignalNotification(settings.m_inputSampleRate, 0);
m_spectrumVis.getInputMessageQueue()->push(msg);
}
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");
}