mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-05 08:21:16 -05:00
Deep redesign: debug WFM demod interpolator init
This commit is contained in:
parent
67866854ca
commit
5582105c25
@ -20,15 +20,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <complex.h>
|
#include <complex.h>
|
||||||
#include "audio/audiooutput.h"
|
#include "audio/audiooutput.h"
|
||||||
|
#include "dsp/dspengine.h"
|
||||||
#include "dsp/channelizer.h"
|
#include "dsp/channelizer.h"
|
||||||
#include "dsp/pidcontroller.h"
|
#include "dsp/pidcontroller.h"
|
||||||
#include "wfmdemod.h"
|
#include "wfmdemod.h"
|
||||||
|
|
||||||
MESSAGE_CLASS_DEFINITION(WFMDemod::MsgConfigureWFMDemod, Message)
|
MESSAGE_CLASS_DEFINITION(WFMDemod::MsgConfigureWFMDemod, Message)
|
||||||
|
|
||||||
WFMDemod::WFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
WFMDemod::WFMDemod(SampleSink* sampleSink) :
|
||||||
m_sampleSink(sampleSink),
|
m_sampleSink(sampleSink),
|
||||||
m_audioFifo(audioFifo)
|
m_audioFifo(4, 250000)
|
||||||
{
|
{
|
||||||
setObjectName("WFMDemod");
|
setObjectName("WFMDemod");
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ WFMDemod::WFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
|||||||
m_config.m_afBandwidth = 15000;
|
m_config.m_afBandwidth = 15000;
|
||||||
m_config.m_squelch = -60.0;
|
m_config.m_squelch = -60.0;
|
||||||
m_config.m_volume = 2.0;
|
m_config.m_volume = 2.0;
|
||||||
m_config.m_audioSampleRate = 48000;
|
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
|
||||||
m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, rfFilterFftLength);
|
m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, rfFilterFftLength);
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
@ -47,6 +48,8 @@ WFMDemod::WFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
|||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
|
|
||||||
m_movingAverage.resize(16, 0);
|
m_movingAverage.resize(16, 0);
|
||||||
|
|
||||||
|
DSPEngine::instance()->addAudioSink(&m_audioFifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
WFMDemod::~WFMDemod()
|
WFMDemod::~WFMDemod()
|
||||||
@ -55,6 +58,8 @@ WFMDemod::~WFMDemod()
|
|||||||
{
|
{
|
||||||
delete m_rfFilter;
|
delete m_rfFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch)
|
void WFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch)
|
||||||
@ -70,7 +75,7 @@ void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
|||||||
int rf_out;
|
int rf_out;
|
||||||
Real msq, demod;
|
Real msq, demod;
|
||||||
|
|
||||||
if (m_audioFifo->size() <= 0)
|
if (m_audioFifo.size() <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (SampleVector::const_iterator it = begin; it != end; ++it)
|
for (SampleVector::const_iterator it = begin; it != end; ++it)
|
||||||
@ -122,9 +127,13 @@ void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
|||||||
|
|
||||||
if(m_audioBufferFill >= m_audioBuffer.size())
|
if(m_audioBufferFill >= m_audioBuffer.size())
|
||||||
{
|
{
|
||||||
uint res = m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
|
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
|
||||||
|
|
||||||
if(res != m_audioBufferFill)
|
if(res != m_audioBufferFill)
|
||||||
qDebug("lost %u samples", m_audioBufferFill - res);
|
{
|
||||||
|
qDebug("WFMDemod::feed: %u/%u audio samples written", res, m_audioBufferFill);
|
||||||
|
}
|
||||||
|
|
||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,25 +142,30 @@ void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_audioBufferFill > 0) {
|
if(m_audioBufferFill > 0)
|
||||||
uint res = m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
|
{
|
||||||
|
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
|
||||||
|
|
||||||
if(res != m_audioBufferFill)
|
if(res != m_audioBufferFill)
|
||||||
qDebug("lost %u samples", m_audioBufferFill - res);
|
{
|
||||||
|
qDebug("WFMDemod::feed: %u/%u tail samples written", res, m_audioBufferFill);
|
||||||
|
}
|
||||||
|
|
||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_sampleSink != NULL)
|
if(m_sampleSink != NULL)
|
||||||
|
{
|
||||||
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), false);
|
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), false);
|
||||||
|
}
|
||||||
|
|
||||||
m_sampleBuffer.clear();
|
m_sampleBuffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WFMDemod::start()
|
void WFMDemod::start()
|
||||||
{
|
{
|
||||||
m_squelchState = 0;
|
m_squelchState = 0;
|
||||||
m_audioFifo->clear();
|
m_audioFifo.clear();
|
||||||
m_interpolatorRegulation = 0.9999;
|
|
||||||
m_interpolatorDistance = 1.0;
|
|
||||||
m_interpolatorDistanceRemain = 0.0;
|
|
||||||
m_m1Sample = 0;
|
m_m1Sample = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,6 +183,7 @@ bool WFMDemod::handleMessage(const Message& cmd)
|
|||||||
|
|
||||||
m_config.m_inputSampleRate = notif.getSampleRate();
|
m_config.m_inputSampleRate = notif.getSampleRate();
|
||||||
m_config.m_inputFrequencyOffset = notif.getFrequencyOffset();
|
m_config.m_inputFrequencyOffset = notif.getFrequencyOffset();
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
|
|
||||||
qDebug() << "WFMDemod::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << m_config.m_inputSampleRate
|
qDebug() << "WFMDemod::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << m_config.m_inputSampleRate
|
||||||
|
@ -30,11 +30,9 @@
|
|||||||
|
|
||||||
#define rfFilterFftLength 1024
|
#define rfFilterFftLength 1024
|
||||||
|
|
||||||
class AudioFifo;
|
|
||||||
|
|
||||||
class WFMDemod : public SampleSink {
|
class WFMDemod : public SampleSink {
|
||||||
public:
|
public:
|
||||||
WFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink);
|
WFMDemod(SampleSink* sampleSink);
|
||||||
virtual ~WFMDemod();
|
virtual ~WFMDemod();
|
||||||
|
|
||||||
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch);
|
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch);
|
||||||
@ -109,8 +107,7 @@ private:
|
|||||||
Config m_running;
|
Config m_running;
|
||||||
|
|
||||||
NCO m_nco;
|
NCO m_nco;
|
||||||
Real m_interpolatorRegulation;
|
Interpolator m_interpolator; //!< Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational)
|
||||||
Interpolator m_interpolator; // Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational)
|
|
||||||
Real m_interpolatorDistance;
|
Real m_interpolatorDistance;
|
||||||
Real m_interpolatorDistanceRemain;
|
Real m_interpolatorDistanceRemain;
|
||||||
Lowpass<Real> m_lowpass;
|
Lowpass<Real> m_lowpass;
|
||||||
@ -120,15 +117,15 @@ private:
|
|||||||
int m_squelchState;
|
int m_squelchState;
|
||||||
|
|
||||||
Real m_lastArgument;
|
Real m_lastArgument;
|
||||||
Complex m_m1Sample; // x^-1 sample
|
Complex m_m1Sample; //!< x^-1 sample
|
||||||
Complex m_m2Sample; // x^-1 sample
|
Complex m_m2Sample; //!< x^-1 sample
|
||||||
MovingAverage<Real> m_movingAverage;
|
MovingAverage<Real> m_movingAverage;
|
||||||
|
|
||||||
AudioVector m_audioBuffer;
|
AudioVector m_audioBuffer;
|
||||||
uint m_audioBufferFill;
|
uint m_audioBufferFill;
|
||||||
|
|
||||||
SampleSink* m_sampleSink;
|
SampleSink* m_sampleSink;
|
||||||
AudioFifo* m_audioFifo;
|
AudioFifo m_audioFifo;
|
||||||
SampleVector m_sampleBuffer;
|
SampleVector m_sampleBuffer;
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
|
@ -211,11 +211,9 @@ WFMDemodGUI::WFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
|||||||
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
||||||
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
||||||
|
|
||||||
m_audioFifo = new AudioFifo(4, 250000); // TODO: check. Room for 1s FIFO at max rate
|
m_wfmDemod = new WFMDemod(0);
|
||||||
m_wfmDemod = new WFMDemod(m_audioFifo, 0);
|
|
||||||
m_channelizer = new Channelizer(m_wfmDemod);
|
m_channelizer = new Channelizer(m_wfmDemod);
|
||||||
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
|
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
|
||||||
DSPEngine::instance()->addAudioSink(m_audioFifo);
|
|
||||||
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
|
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
|
||||||
|
|
||||||
m_channelMarker = new ChannelMarker(this);
|
m_channelMarker = new ChannelMarker(this);
|
||||||
@ -232,12 +230,10 @@ WFMDemodGUI::WFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
|||||||
WFMDemodGUI::~WFMDemodGUI()
|
WFMDemodGUI::~WFMDemodGUI()
|
||||||
{
|
{
|
||||||
m_pluginAPI->removeChannelInstance(this);
|
m_pluginAPI->removeChannelInstance(this);
|
||||||
DSPEngine::instance()->removeAudioSink(m_audioFifo);
|
|
||||||
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
|
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
|
||||||
delete m_threadedChannelizer;
|
delete m_threadedChannelizer;
|
||||||
delete m_channelizer;
|
delete m_channelizer;
|
||||||
delete m_wfmDemod;
|
delete m_wfmDemod;
|
||||||
delete m_audioFifo;
|
|
||||||
delete m_channelMarker;
|
delete m_channelMarker;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
class PluginAPI;
|
class PluginAPI;
|
||||||
class ChannelMarker;
|
class ChannelMarker;
|
||||||
|
|
||||||
class AudioFifo;
|
|
||||||
class ThreadedSampleSink;
|
class ThreadedSampleSink;
|
||||||
class Channelizer;
|
class Channelizer;
|
||||||
class WFMDemod;
|
class WFMDemod;
|
||||||
@ -51,7 +50,6 @@ private:
|
|||||||
bool m_basicSettingsShown;
|
bool m_basicSettingsShown;
|
||||||
bool m_doApplySettings;
|
bool m_doApplySettings;
|
||||||
|
|
||||||
AudioFifo* m_audioFifo;
|
|
||||||
ThreadedSampleSink* m_threadedChannelizer;
|
ThreadedSampleSink* m_threadedChannelizer;
|
||||||
Channelizer* m_channelizer;
|
Channelizer* m_channelizer;
|
||||||
WFMDemod* m_wfmDemod;
|
WFMDemod* m_wfmDemod;
|
||||||
|
Loading…
Reference in New Issue
Block a user