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

pull/820/head
Jon Beniston 2021-03-27 10:07:23 +00:00
rodzic 2c2cf314b1
commit 0b05fcc250
6 zmienionych plików z 54 dodań i 6 usunięć

Wyświetl plik

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

Wyświetl plik

@ -78,6 +78,11 @@ void PacketDemodBaseband::stopWork()
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)
{
m_sampleFifo.write(begin, end);

Wyświetl plik

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

Wyświetl plik

@ -21,7 +21,7 @@
#include <complex.h>
#include "dsp/dspengine.h"
#include "dsp/dspengine.h"
#include "dsp/datafifo.h"
#include "util/db.h"
#include "util/stepfunctions.h"
#include "pipes/pipeendpoint.h"
@ -46,6 +46,9 @@ PacketDemodSink::PacketDemodSink(PacketDemod *packetDemod) :
{
m_magsq = 0.0;
m_demodBuffer.resize(1<<12);
m_demodBufferFill = 0;
applySettings(m_settings, true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
}
@ -236,6 +239,24 @@ void PacketDemodSink::processOneSample(Complex &ci)
}
m_corrIdx = (m_corrIdx + 1) % m_correlationLength;
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)
@ -252,9 +273,9 @@ void PacketDemodSink::applyChannelSettings(int channelSampleRate, int channelFre
if ((m_channelSampleRate != channelSampleRate) || force)
{
m_interpolator.create(16, channelSampleRate, PACKETDEMOD_CHANNEL_BANDWIDTH);
m_interpolatorDistanceRemain = 0;
m_interpolator.create(16, channelSampleRate, m_settings.m_rfBandwidth / 2.2);
m_interpolatorDistance = (Real) channelSampleRate / (Real) PACKETDEMOD_CHANNEL_SAMPLE_RATE;
m_interpolatorDistanceRemain = m_interpolatorDistance;
}
m_channelSampleRate = channelSampleRate;
@ -266,11 +287,20 @@ void PacketDemodSink::applySettings(const PacketDemodSettings& settings, bool fo
qDebug() << "PacketDemodSink::applySettings:"
<< " 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)
{
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_f0;
delete m_corrBuf;

Wyświetl plik

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

Wyświetl plik

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