mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
Morse Decoder: added scope
This commit is contained in:
parent
112cd4cac4
commit
8e9661f011
@ -196,7 +196,7 @@ MorseDecoderGUI::MorseDecoderGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISe
|
||||
m_scopeVis = m_morseDecoder->getScopeVis();
|
||||
m_scopeVis->setGLScope(ui->glScope);
|
||||
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
|
||||
m_scopeVis->setLiveRate(4000);
|
||||
m_scopeVis->setLiveRate(1484/4.7488);
|
||||
|
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
||||
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||
|
@ -477,280 +477,6 @@
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="scopelLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="channel1Label">
|
||||
<property name="text">
|
||||
<string>Real</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="channel1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>I</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Q</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Mag Sq</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Sample Idx</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>abs(Sum1)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>abs(Sum2)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bit</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bit Cnt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Got SOP</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Real(exp)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Imag(exp)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>abs(sum1)Filt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>abs(sum2)Filt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Diff</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>DiffFilt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>data</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>clock</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Env1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Env2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bias1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bias2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Unbiased data</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Biased data</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="channel2Label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Imag</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="channel2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>I</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Q</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Mag Sq</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Sample Idx</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>abs(Sum1)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>abs(Sum2)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bit</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bit Cnt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Got SOP</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Real(exp)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>imag(exp)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>abs(sum1)Filt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>abs(sum2)Filt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Diff</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>DiffFilt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>data</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>clock</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Env1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Env2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bias1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bias2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Unbiased data</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Biased data</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GLScope" name="glScope" native="true">
|
||||
<property name="minimumSize">
|
||||
|
@ -16,6 +16,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
|
||||
#include "dsp/scopevis.h"
|
||||
#include "dsp/datafifo.h"
|
||||
@ -31,7 +32,9 @@ MorseDecoderWorker::MorseDecoderWorker() :
|
||||
m_msgQueueToFeature(nullptr),
|
||||
m_auto(false),
|
||||
m_pitchHz(-1),
|
||||
m_speedWPM(-1)
|
||||
m_speedWPM(-1),
|
||||
m_scopeVis(nullptr),
|
||||
m_pollTimer(nullptr)
|
||||
{
|
||||
qDebug("MorseDecoderWorker::MorseDecoderWorker");
|
||||
m_ggMorseParameters = new GGMorse::Parameters{
|
||||
@ -50,6 +53,7 @@ MorseDecoderWorker::MorseDecoderWorker() :
|
||||
|
||||
MorseDecoderWorker::~MorseDecoderWorker()
|
||||
{
|
||||
|
||||
m_inputMessageQueue.clear();
|
||||
delete m_ggMorse;
|
||||
delete m_ggMorseParameters;
|
||||
@ -63,14 +67,23 @@ void MorseDecoderWorker::reset()
|
||||
|
||||
void MorseDecoderWorker::startWork()
|
||||
{
|
||||
qDebug("MorseDecoderWorker::startWork");
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||
|
||||
m_pollTimer = new QTimer();
|
||||
connect(m_pollTimer, SIGNAL(timeout()), this, SLOT(pollingTick()));
|
||||
m_pollTimer->start(1000);
|
||||
}
|
||||
|
||||
void MorseDecoderWorker::stopWork()
|
||||
{
|
||||
qDebug("MorseDecoderWorker::stopWork");
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||
disconnect(m_pollTimer, SIGNAL(timeout()), this, SLOT(pollingTick()));
|
||||
m_pollTimer->stop();
|
||||
delete m_pollTimer;
|
||||
}
|
||||
|
||||
void MorseDecoderWorker::feedPart(
|
||||
@ -103,7 +116,7 @@ void MorseDecoderWorker::feedPart(
|
||||
if (countBytes >= bytesLeft)
|
||||
{
|
||||
std::copy(m_convBuffer.begin(), m_convBuffer.begin() + bytesLeft, m_bytesBuffer.begin() + m_bytesBufferCount); // fill buffer
|
||||
int unprocessedBytes = processBuffer(m_convBuffer);
|
||||
int unprocessedBytes = processBuffer(m_convBuffer, countBytes);
|
||||
std::copy(m_convBuffer.begin() + bytesLeft - unprocessedBytes, m_convBuffer.end(), m_bytesBuffer.begin());
|
||||
m_bytesBufferCount = bytesLeft + unprocessedBytes;
|
||||
}
|
||||
@ -118,7 +131,7 @@ void MorseDecoderWorker::feedPart(
|
||||
if (countBytes >= bytesLeft)
|
||||
{
|
||||
std::copy(begin, begin + bytesLeft, m_bytesBuffer.begin() + m_bytesBufferCount); // fill buffer
|
||||
int unprocessedBytes = processBuffer(m_bytesBuffer);
|
||||
int unprocessedBytes = processBuffer(m_bytesBuffer, countBytes);
|
||||
std::copy(begin + bytesLeft - unprocessedBytes, end, m_bytesBuffer.begin());
|
||||
m_bytesBufferCount = bytesLeft + unprocessedBytes;
|
||||
}
|
||||
@ -130,7 +143,7 @@ void MorseDecoderWorker::feedPart(
|
||||
}
|
||||
}
|
||||
|
||||
int MorseDecoderWorker::processBuffer(QByteArray& bytesBuffer)
|
||||
int MorseDecoderWorker::processBuffer(QByteArray& bytesBuffer, int countBytes)
|
||||
{
|
||||
uint32_t samplesHave = bytesBuffer.size() / 2;
|
||||
uint32_t samplesTotal = bytesBuffer.size() / 2;
|
||||
@ -143,8 +156,8 @@ int MorseDecoderWorker::processBuffer(QByteArray& bytesBuffer)
|
||||
if (samplesHave != 0)
|
||||
{
|
||||
bytesLeft = samplesHave*2;
|
||||
qDebug("MorseDecoderWorker::processBuffer::cbWaveformInp: nMaxBytes: %u / %u samples left buffer size: %u",
|
||||
nMaxBytes, samplesHave, bytesBuffer.size());
|
||||
qDebug("MorseDecoderWorker::processBuffer::cbWaveformInp: nMaxBytes: %u / %u samples left buffer size: %u countBytes: %d",
|
||||
nMaxBytes, samplesHave, bytesBuffer.size(), countBytes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -183,6 +196,36 @@ int MorseDecoderWorker::processBuffer(QByteArray& bytesBuffer)
|
||||
msg->m_signalThreshold = stats.signalThreshold;
|
||||
m_msgQueueToFeature->push(msg);
|
||||
}
|
||||
|
||||
if (m_scopeVis)
|
||||
{
|
||||
std::vector<float> trace;
|
||||
int traceSize = m_ggMorse->takeSignalF(trace);
|
||||
std::vector<float> thresholds;
|
||||
int thrSize = m_ggMorse->takeThresholdF(thresholds);
|
||||
qDebug("MorseDecoderWorker::processBuffer: traceSize: %d thrSize: %d", traceSize, thrSize);
|
||||
int i = 0;
|
||||
int d = (traceSize / thrSize) + 1;
|
||||
|
||||
if (traceSize != 0)
|
||||
{
|
||||
SampleVector strace;
|
||||
strace.resize(traceSize);
|
||||
std::transform(
|
||||
trace.begin(),
|
||||
trace.end(),
|
||||
strace.begin(),
|
||||
[&](float& t) {
|
||||
float im = thresholds[i/d];
|
||||
i++;
|
||||
return Sample(t*SDR_RX_SCALEF, im*SDR_RX_SCALEF);
|
||||
}
|
||||
);
|
||||
std::vector<SampleVector::const_iterator> vbegin;
|
||||
vbegin.push_back(strace.begin());
|
||||
m_scopeVis->feed(vbegin, traceSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bytesLeft;
|
||||
@ -284,8 +327,8 @@ void MorseDecoderWorker::applySampleRate(int sampleRate)
|
||||
m_sinkSampleRate = sampleRate;
|
||||
m_ggMorseParameters->sampleRateInp = sampleRate;
|
||||
int ggMorseBlockSize = (sampleRate / GGMorse::kBaseSampleRate)*GGMorse::kDefaultSamplesPerFrame;
|
||||
// m_bytesBufferSize = (GGMorse::kBaseSampleRate/GGMorse::kDefaultSamplesPerFrame)*ggMorseBlockSize*10; // ~10s
|
||||
m_bytesBufferSize = sampleRate*10 + ggMorseBlockSize;
|
||||
// m_bytesBufferSize = (GGMorse::kBaseSampleRate/GGMorse::kDefaultSamplesPerFrame)*ggMorseBlockSize*10; // ~5s
|
||||
m_bytesBufferSize = sampleRate*9.4976; // + ggMorseBlockSize;
|
||||
m_bytesBuffer.resize(m_bytesBufferSize);
|
||||
m_bytesBufferCount = 0;
|
||||
qDebug("MorseDecoderWorker::applySampleRate: m_sinkSampleRate: %d ggMorseBlockSize: %d m_bytesBufferSize: %d",
|
||||
@ -319,3 +362,7 @@ void MorseDecoderWorker::handleData()
|
||||
m_dataFifo->readCommit((unsigned int) count);
|
||||
}
|
||||
}
|
||||
|
||||
void MorseDecoderWorker::pollingTick()
|
||||
{
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "morsedecodersettings.h"
|
||||
|
||||
class ScopeVis;
|
||||
class QTimer;
|
||||
|
||||
class MorseDecoderWorker : public QObject {
|
||||
Q_OBJECT
|
||||
@ -115,6 +116,7 @@ private:
|
||||
float m_pitchHz;
|
||||
float m_speedWPM;
|
||||
ScopeVis* m_scopeVis;
|
||||
QTimer *m_pollTimer;
|
||||
|
||||
void feedPart(
|
||||
const QByteArray::const_iterator& begin,
|
||||
@ -123,7 +125,7 @@ private:
|
||||
);
|
||||
|
||||
bool handleMessage(const Message& cmd);
|
||||
int processBuffer(QByteArray& bytesBuffer); //!< return the number of bytes left
|
||||
int processBuffer(QByteArray& bytesBuffer, int countBytes); //!< return the number of bytes left
|
||||
|
||||
// inline void processSample(
|
||||
// DataFifo::DataType dataType,
|
||||
@ -152,6 +154,7 @@ private:
|
||||
private slots:
|
||||
void handleInputMessages();
|
||||
void handleData(); //!< Handle data when samples have to be processed
|
||||
void pollingTick();
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FEATURE_MORSEDECODERWORKER_H_
|
||||
|
Loading…
Reference in New Issue
Block a user