mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 01:39:05 -05:00
Add support for Broadcast FM Demod to send audio to Demod Analyzer feature
This commit is contained in:
parent
7d1e8f8028
commit
501d8515eb
@ -59,6 +59,7 @@ BFMDemod::BFMDemod(DeviceAPI *deviceAPI) :
|
||||
m_thread = new QThread(this);
|
||||
m_basebandSink = new BFMDemodBaseband();
|
||||
m_basebandSink->setSpectrumSink(&m_spectrumVis);
|
||||
m_basebandSink->setChannel(this);
|
||||
m_basebandSink->moveToThread(m_thread);
|
||||
|
||||
applySettings(m_settings, true);
|
||||
|
@ -69,6 +69,11 @@ void BFMDemodBaseband::feed(const SampleVector::const_iterator& begin, const Sam
|
||||
m_sampleFifo.write(begin, end);
|
||||
}
|
||||
|
||||
void BFMDemodBaseband::setChannel(ChannelAPI *channel)
|
||||
{
|
||||
m_sink.setChannel(channel);
|
||||
}
|
||||
|
||||
void BFMDemodBaseband::handleData()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
int getChannelSampleRate() const;
|
||||
void setBasebandSampleRate(int sampleRate);
|
||||
void setSpectrumSink(SpectrumVis* spectrumSink) { m_spectrumVis = spectrumSink; m_sink.setSpectrumSink((BasebandSampleSink*) spectrumSink); }
|
||||
void setChannel(ChannelAPI *channel);
|
||||
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_messageQueueToGUI = messageQueue; }
|
||||
|
||||
int getAudioSampleRate() const { return m_sink.getAudioSampleRate(); }
|
||||
|
@ -27,7 +27,10 @@
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/devicesamplemimo.h"
|
||||
#include "dsp/basebandsamplesink.h"
|
||||
#include "dsp/datafifo.h"
|
||||
#include "pipes/datapipes.h"
|
||||
#include "util/db.h"
|
||||
#include "maincore.h"
|
||||
|
||||
#include "rdsparser.h"
|
||||
#include "bfmdemodsink.h"
|
||||
@ -36,6 +39,7 @@ const Real BFMDemodSink::default_deemphasis = 50.0; // 50 us
|
||||
const int BFMDemodSink::default_excursion = 750000; // +/- 75 kHz
|
||||
|
||||
BFMDemodSink::BFMDemodSink() :
|
||||
m_channel(nullptr),
|
||||
m_channelSampleRate(48000),
|
||||
m_channelFrequencyOffset(0),
|
||||
m_audioSampleRate(48000),
|
||||
@ -75,6 +79,9 @@ BFMDemodSink::BFMDemodSink() :
|
||||
m_audioBuffer.resize(1<<14);
|
||||
m_audioBufferFill = 0;
|
||||
|
||||
m_demodBuffer.resize(1<<13);
|
||||
m_demodBufferFill = 0;
|
||||
|
||||
applySettings(m_settings, true);
|
||||
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
|
||||
}
|
||||
@ -211,6 +218,9 @@ void BFMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV
|
||||
m_audioBuffer[m_audioBufferFill].r = sample;
|
||||
}
|
||||
|
||||
m_demodBuffer[m_demodBufferFill++] = m_audioBuffer[m_audioBufferFill].l;
|
||||
m_demodBuffer[m_demodBufferFill++] = m_audioBuffer[m_audioBufferFill].r;
|
||||
|
||||
++m_audioBufferFill;
|
||||
|
||||
if (m_audioBufferFill >= m_audioBuffer.size())
|
||||
@ -224,6 +234,28 @@ void BFMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV
|
||||
m_audioBufferFill = 0;
|
||||
}
|
||||
|
||||
if (m_demodBufferFill >= m_demodBuffer.size())
|
||||
{
|
||||
QList<ObjectPipe*> dataPipes;
|
||||
MainCore::instance()->getDataPipes().getDataPipes(m_channel, "demod", dataPipes);
|
||||
|
||||
if (dataPipes.size() > 0)
|
||||
{
|
||||
QList<ObjectPipe*>::iterator it = dataPipes.begin();
|
||||
|
||||
for (; it != dataPipes.end(); ++it)
|
||||
{
|
||||
DataFifo *fifo = qobject_cast<DataFifo*>((*it)->m_element);
|
||||
|
||||
if (fifo) {
|
||||
fifo->write((quint8*) &m_demodBuffer[0], m_demodBuffer.size() * sizeof(qint16), DataFifo::DataTypeCI16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_demodBufferFill = 0;
|
||||
}
|
||||
|
||||
m_interpolatorDistanceRemain += m_interpolatorDistance;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "rdsdemod.h"
|
||||
#include "bfmdemodsettings.h"
|
||||
|
||||
class ChannelAPI;
|
||||
class BasebandSampleSink;
|
||||
|
||||
class BFMDemodSink : public ChannelSampleSink {
|
||||
@ -46,6 +47,7 @@ public:
|
||||
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
|
||||
|
||||
void setSpectrumSink(BasebandSampleSink* spectrumSink) { m_spectrumSink = spectrumSink; }
|
||||
void setChannel(ChannelAPI *channel) { m_channel = channel; }
|
||||
|
||||
double getMagSq() const { return m_magsq; }
|
||||
|
||||
@ -103,6 +105,7 @@ private:
|
||||
RSRunning
|
||||
};
|
||||
|
||||
ChannelAPI *m_channel;
|
||||
int m_channelSampleRate;
|
||||
int m_channelFrequencyOffset;
|
||||
BFMDemodSettings m_settings;
|
||||
@ -158,6 +161,9 @@ private:
|
||||
PhaseDiscriminators m_phaseDiscri;
|
||||
|
||||
BasebandSampleSink *m_spectrumSink;
|
||||
|
||||
QVector<qint16> m_demodBuffer;
|
||||
int m_demodBufferFill;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_BFMDEMODSINK_H
|
||||
|
@ -27,6 +27,7 @@ const QStringList DemodAnalyzerSettings::m_channelTypes = {
|
||||
QStringLiteral("AISMod"),
|
||||
QStringLiteral("AMDemod"),
|
||||
QStringLiteral("AMMod"),
|
||||
QStringLiteral("BFMDemod"),
|
||||
QStringLiteral("DABDemod"),
|
||||
QStringLiteral("DSDDemod"),
|
||||
QStringLiteral("NFMDemod"),
|
||||
@ -45,6 +46,7 @@ const QStringList DemodAnalyzerSettings::m_channelURIs = {
|
||||
QStringLiteral("sdrangel.channel.modais"),
|
||||
QStringLiteral("sdrangel.channel.amdemod"),
|
||||
QStringLiteral("sdrangel.channeltx.modam"),
|
||||
QStringLiteral("sdrangel.channel.bfm"),
|
||||
QStringLiteral("sdrangel.channel.dabdemod"),
|
||||
QStringLiteral("sdrangel.channel.dsddemod"),
|
||||
QStringLiteral("sdrangel.channel.nfmdemod"),
|
||||
|
Loading…
Reference in New Issue
Block a user