1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Bring BFM demod closer to AM demod design.

This commit is contained in:
srcejon 2024-05-08 18:43:19 +01:00
parent 605cf51d7f
commit 60db324abc
5 changed files with 13 additions and 11 deletions

View File

@ -76,7 +76,6 @@ BFMDemod::BFMDemod(DeviceAPI *deviceAPI) :
this, this,
&BFMDemod::handleIndexInDeviceSetChanged &BFMDemod::handleIndexInDeviceSetChanged
); );
start();
} }
BFMDemod::~BFMDemod() BFMDemod::~BFMDemod()
@ -129,21 +128,25 @@ void BFMDemod::start()
m_basebandSink->setSpectrumSink(&m_spectrumVis); m_basebandSink->setSpectrumSink(&m_spectrumVis);
m_basebandSink->setChannel(this); m_basebandSink->setChannel(this);
m_basebandSink->moveToThread(m_thread); m_basebandSink->moveToThread(m_thread);
m_basebandSink->setMessageQueueToGUI(getMessageQueueToGUI());
QObject::connect(m_thread, &QThread::finished, m_basebandSink, &QObject::deleteLater); QObject::connect(m_thread, &QThread::finished, m_basebandSink, &QObject::deleteLater);
QObject::connect(m_thread, &QThread::finished, m_thread, &QThread::deleteLater); QObject::connect(m_thread, &QThread::finished, m_thread, &QThread::deleteLater);
if (m_basebandSampleRate != 0) {
m_basebandSink->setBasebandSampleRate(m_basebandSampleRate);
}
m_basebandSink->reset(); m_basebandSink->reset();
m_basebandSink->startWork(); m_basebandSink->startWork();
m_thread->start(); m_thread->start();
DSPSignalNotification *dspMsg = new DSPSignalNotification(m_basebandSampleRate, 0);
m_basebandSink->getInputMessageQueue()->push(dspMsg);
BFMDemodBaseband::MsgConfigureBFMDemodBaseband *msg = BFMDemodBaseband::MsgConfigureBFMDemodBaseband::create(m_settings, true);
m_basebandSink->getInputMessageQueue()->push(msg);
SpectrumSettings spectrumSettings = m_spectrumVis.getSettings(); SpectrumSettings spectrumSettings = m_spectrumVis.getSettings();
spectrumSettings.m_ssb = true; spectrumSettings.m_ssb = true;
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false); SpectrumVis::MsgConfigureSpectrumVis *visMsg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
m_spectrumVis.getInputMessageQueue()->push(msg); m_spectrumVis.getInputMessageQueue()->push(visMsg);
m_running = true; m_running = true;
} }

View File

@ -76,7 +76,6 @@ public:
virtual void setDeviceAPI(DeviceAPI *deviceAPI); virtual void setDeviceAPI(DeviceAPI *deviceAPI);
virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; } virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; }
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
void setBasebandMessageQueueToGUI(MessageQueue *messageQueue) { m_basebandSink->setMessageQueueToGUI(messageQueue); }
using BasebandSampleSink::feed; using BasebandSampleSink::feed;
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);

View File

@ -43,8 +43,6 @@ BFMDemodBaseband::BFMDemodBaseband() :
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue()); DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue());
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate()); m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_channelSampleRate = 0; m_channelSampleRate = 0;
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
} }
BFMDemodBaseband::~BFMDemodBaseband() BFMDemodBaseband::~BFMDemodBaseband()
@ -56,6 +54,7 @@ BFMDemodBaseband::~BFMDemodBaseband()
void BFMDemodBaseband::reset() void BFMDemodBaseband::reset()
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
m_inputMessageQueue.clear();
m_sampleFifo.reset(); m_sampleFifo.reset();
m_channelSampleRate = 0; m_channelSampleRate = 0;
} }

View File

@ -413,7 +413,6 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
m_spectrumVis = m_bfmDemod->getSpectrumVis(); m_spectrumVis = m_bfmDemod->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum); m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_bfmDemod->setMessageQueueToGUI(getInputMessageQueue()); m_bfmDemod->setMessageQueueToGUI(getInputMessageQueue());
m_bfmDemod->setBasebandMessageQueueToGUI(getInputMessageQueue());
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum); ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);

View File

@ -222,8 +222,10 @@ void BFMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV
{ {
std::size_t res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], std::min(m_audioBufferFill, m_audioBuffer.size())); std::size_t res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], std::min(m_audioBufferFill, m_audioBuffer.size()));
if(res != m_audioBufferFill) { if (res != m_audioBufferFill)
{
qDebug("BFMDemodSink::feed: %lu/%lu audio samples written", res, m_audioBufferFill); qDebug("BFMDemodSink::feed: %lu/%lu audio samples written", res, m_audioBufferFill);
m_audioFifo.clear();
} }
m_audioBufferFill = 0; m_audioBufferFill = 0;