1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 04:41:55 -05:00

Add support for Packet demodulator to Demod Analyzer feature. Use RF bandwidth setting for interpolator

This commit is contained in:
Jon Beniston 2021-03-27 10:07:23 +00:00
parent 2c2cf314b1
commit 0b05fcc250
6 changed files with 54 additions and 6 deletions

View File

@ -54,6 +54,7 @@ PacketDemod::PacketDemod(DeviceAPI *deviceAPI) :
m_basebandSink = new PacketDemodBaseband(this); m_basebandSink = new PacketDemodBaseband(this);
m_basebandSink->setMessageQueueToChannel(getInputMessageQueue()); m_basebandSink->setMessageQueueToChannel(getInputMessageQueue());
m_basebandSink->setChannel(this);
m_basebandSink->moveToThread(&m_thread); m_basebandSink->moveToThread(&m_thread);
applySettings(m_settings, true); applySettings(m_settings, true);

View File

@ -78,6 +78,11 @@ void PacketDemodBaseband::stopWork()
m_running = false; m_running = false;
} }
void PacketDemodBaseband::setChannel(ChannelAPI *channel)
{
m_sink.setChannel(channel);
}
void PacketDemodBaseband::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end) void PacketDemodBaseband::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end)
{ {
m_sampleFifo.write(begin, end); m_sampleFifo.write(begin, end);

View File

@ -29,6 +29,7 @@
#include "packetdemodsink.h" #include "packetdemodsink.h"
class DownChannelizer; class DownChannelizer;
class ChannelAPI;
class PacketDemod; class PacketDemod;
class PacketDemodBaseband : public QObject class PacketDemodBaseband : public QObject
@ -70,6 +71,7 @@ public:
} }
void setMessageQueueToChannel(MessageQueue *messageQueue) { m_sink.setMessageQueueToChannel(messageQueue); } void setMessageQueueToChannel(MessageQueue *messageQueue) { m_sink.setMessageQueueToChannel(messageQueue); }
void setBasebandSampleRate(int sampleRate); void setBasebandSampleRate(int sampleRate);
void setChannel(ChannelAPI *channel);
double getMagSq() const { return m_sink.getMagSq(); } double getMagSq() const { return m_sink.getMagSq(); }
bool isRunning() const { return m_running; } bool isRunning() const { return m_running; }

View File

@ -21,7 +21,7 @@
#include <complex.h> #include <complex.h>
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspengine.h" #include "dsp/datafifo.h"
#include "util/db.h" #include "util/db.h"
#include "util/stepfunctions.h" #include "util/stepfunctions.h"
#include "pipes/pipeendpoint.h" #include "pipes/pipeendpoint.h"
@ -46,6 +46,9 @@ PacketDemodSink::PacketDemodSink(PacketDemod *packetDemod) :
{ {
m_magsq = 0.0; m_magsq = 0.0;
m_demodBuffer.resize(1<<12);
m_demodBufferFill = 0;
applySettings(m_settings, true); applySettings(m_settings, true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true); applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
} }
@ -236,6 +239,24 @@ void PacketDemodSink::processOneSample(Complex &ci)
} }
m_corrIdx = (m_corrIdx + 1) % m_correlationLength; m_corrIdx = (m_corrIdx + 1) % m_correlationLength;
m_corrCnt++; m_corrCnt++;
m_demodBuffer[m_demodBufferFill++] = fmDemod * std::numeric_limits<int16_t>::max();
if (m_demodBufferFill >= m_demodBuffer.size())
{
QList<DataFifo*> *dataFifos = MainCore::instance()->getDataPipes().getFifos(m_channel, "demod");
if (dataFifos)
{
QList<DataFifo*>::iterator it = dataFifos->begin();
for (; it != dataFifos->end(); ++it) {
(*it)->write((quint8*) &m_demodBuffer[0], m_demodBuffer.size() * sizeof(qint16));
}
}
m_demodBufferFill = 0;
}
} }
void PacketDemodSink::applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force) void PacketDemodSink::applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force)
@ -252,9 +273,9 @@ void PacketDemodSink::applyChannelSettings(int channelSampleRate, int channelFre
if ((m_channelSampleRate != channelSampleRate) || force) if ((m_channelSampleRate != channelSampleRate) || force)
{ {
m_interpolator.create(16, channelSampleRate, PACKETDEMOD_CHANNEL_BANDWIDTH); m_interpolator.create(16, channelSampleRate, m_settings.m_rfBandwidth / 2.2);
m_interpolatorDistanceRemain = 0;
m_interpolatorDistance = (Real) channelSampleRate / (Real) PACKETDEMOD_CHANNEL_SAMPLE_RATE; m_interpolatorDistance = (Real) channelSampleRate / (Real) PACKETDEMOD_CHANNEL_SAMPLE_RATE;
m_interpolatorDistanceRemain = m_interpolatorDistance;
} }
m_channelSampleRate = channelSampleRate; m_channelSampleRate = channelSampleRate;
@ -266,11 +287,20 @@ void PacketDemodSink::applySettings(const PacketDemodSettings& settings, bool fo
qDebug() << "PacketDemodSink::applySettings:" qDebug() << "PacketDemodSink::applySettings:"
<< " force: " << force; << " force: " << force;
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force)
{
m_interpolator.create(16, m_channelSampleRate, settings.m_rfBandwidth / 2.2);
m_interpolatorDistance = (Real) m_channelSampleRate / (Real) PACKETDEMOD_CHANNEL_SAMPLE_RATE;
m_interpolatorDistanceRemain = m_interpolatorDistance;
m_lowpass.create(301, PACKETDEMOD_CHANNEL_SAMPLE_RATE, settings.m_rfBandwidth / 2.0f);
}
if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force)
{
m_phaseDiscri.setFMScaling(PACKETDEMOD_CHANNEL_SAMPLE_RATE / (2.0f * settings.m_fmDeviation));
}
if (force) if (force)
{ {
m_lowpass.create(301, PACKETDEMOD_CHANNEL_SAMPLE_RATE, settings.m_rfBandwidth / 2.0f);
m_phaseDiscri.setFMScaling(PACKETDEMOD_CHANNEL_SAMPLE_RATE / (2.0f * settings.m_fmDeviation));
delete m_f1; delete m_f1;
delete m_f0; delete m_f0;
delete m_corrBuf; delete m_corrBuf;

View File

@ -19,6 +19,8 @@
#ifndef INCLUDE_PACKETDEMODSINK_H #ifndef INCLUDE_PACKETDEMODSINK_H
#define INCLUDE_PACKETDEMODSINK_H #define INCLUDE_PACKETDEMODSINK_H
#include <QVector>
#include "dsp/channelsamplesink.h" #include "dsp/channelsamplesink.h"
#include "dsp/phasediscri.h" #include "dsp/phasediscri.h"
#include "dsp/nco.h" #include "dsp/nco.h"
@ -39,6 +41,7 @@
// Must be integer multiple of m_baud=1200 // Must be integer multiple of m_baud=1200
#define PACKETDEMOD_CHANNEL_SAMPLE_RATE 38400 #define PACKETDEMOD_CHANNEL_SAMPLE_RATE 38400
class ChannelAPI;
class PacketDemod; class PacketDemod;
class PacketDemodSink : public ChannelSampleSink { class PacketDemodSink : public ChannelSampleSink {
@ -51,6 +54,7 @@ public:
void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false); void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false);
void applySettings(const PacketDemodSettings& settings, bool force = false); void applySettings(const PacketDemodSettings& settings, bool force = false);
void setMessageQueueToChannel(MessageQueue *messageQueue) { m_messageQueueToChannel = messageQueue; } void setMessageQueueToChannel(MessageQueue *messageQueue) { m_messageQueueToChannel = messageQueue; }
void setChannel(ChannelAPI *channel) { m_channel = channel; }
double getMagSq() const { return m_magsq; } double getMagSq() const { return m_magsq; }
@ -86,6 +90,7 @@ private:
PacketDemod *m_packetDemod; PacketDemod *m_packetDemod;
PacketDemodSettings m_settings; PacketDemodSettings m_settings;
ChannelAPI *m_channel;
int m_channelSampleRate; int m_channelSampleRate;
int m_channelFrequencyOffset; int m_channelFrequencyOffset;
@ -128,6 +133,9 @@ private:
int m_byteCount; int m_byteCount;
crc16x25 m_crc; crc16x25 m_crc;
QVector<qint16> m_demodBuffer;
int m_demodBufferFill;
void processOneSample(Complex &ci); void processOneSample(Complex &ci);
MessageQueue *getMessageQueueToChannel() { return m_messageQueueToChannel; } MessageQueue *getMessageQueueToChannel() { return m_messageQueueToChannel; }
}; };

View File

@ -28,6 +28,7 @@ const QStringList DemodAnalyzerSettings::m_channelTypes = {
QStringLiteral("DSDDemod"), QStringLiteral("DSDDemod"),
QStringLiteral("NFMDemod"), QStringLiteral("NFMDemod"),
QStringLiteral("NFMMod"), QStringLiteral("NFMMod"),
QStringLiteral("PacketDemod"),
QStringLiteral("PacketMod"), QStringLiteral("PacketMod"),
QStringLiteral("SSBDemod"), QStringLiteral("SSBDemod"),
QStringLiteral("SSBMod"), QStringLiteral("SSBMod"),
@ -41,6 +42,7 @@ const QStringList DemodAnalyzerSettings::m_channelURIs = {
QStringLiteral("sdrangel.channel.dsddemod"), QStringLiteral("sdrangel.channel.dsddemod"),
QStringLiteral("sdrangel.channel.nfmdemod"), QStringLiteral("sdrangel.channel.nfmdemod"),
QStringLiteral("sdrangel.channeltx.modnfm"), QStringLiteral("sdrangel.channeltx.modnfm"),
QStringLiteral("sdrangel.channel.packetdemod"),
QStringLiteral("sdrangel.channeltx.modpacket"), QStringLiteral("sdrangel.channeltx.modpacket"),
QStringLiteral("sdrangel.channel.ssbdemod"), QStringLiteral("sdrangel.channel.ssbdemod"),
QStringLiteral("sdrangel.channeltx.modssb"), QStringLiteral("sdrangel.channeltx.modssb"),