SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BFMDemod Class Reference

#include <bfmdemod.h>

+ Inheritance diagram for BFMDemod:
+ Collaboration diagram for BFMDemod:

Classes

struct  MagSqLevelsStore
 
class  MsgConfigureBFMDemod
 
class  MsgConfigureChannelizer
 
class  MsgReportChannelSampleRateChanged
 

Public Member Functions

 BFMDemod (DeviceAPI *deviceAPI)
 
virtual ~BFMDemod ()
 
virtual void destroy ()
 
void setSampleSink (BasebandSampleSink *sampleSink)
 
int getSampleRate () const
 
virtual void feed (const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool po)
 
virtual void start ()
 
virtual void stop ()
 
virtual bool handleMessage (const Message &cmd)
 Processing of a message. Returns true if message has actually been processed. More...
 
virtual void getIdentifier (QString &id)
 
virtual void getTitle (QString &title)
 
virtual qint64 getCenterFrequency () const
 Applies to a default stream. More...
 
virtual QByteArray serialize () const
 
virtual bool deserialize (const QByteArray &data)
 
virtual int getNbSinkStreams () const
 
virtual int getNbSourceStreams () const
 
virtual qint64 getStreamCenterFrequency (int streamIndex, bool sinkElseSource) const
 
double getMagSq () const
 
bool getPilotLock () const
 
Real getPilotLevel () const
 
Real getDecoderQua () const
 
bool getDecoderSynced () const
 
Real getDemodAcc () const
 
Real getDemodQua () const
 
Real getDemodFclk () const
 
void getMagSqLevels (double &avg, double &peak, int &nbSamples)
 
RDSParsergetRDSParser ()
 
virtual int webapiSettingsGet (SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
 
virtual int webapiSettingsPutPatch (bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
 
virtual int webapiReportGet (SWGSDRangel::SWGChannelReport &response, QString &errorMessage)
 
- Public Member Functions inherited from BasebandSampleSink
 BasebandSampleSink ()
 
virtual ~BasebandSampleSink ()
 
MessageQueuegetInputMessageQueue ()
 Get the queue for asynchronous inbound communication. More...
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
MessageQueuegetMessageQueueToGUI ()
 
- Public Member Functions inherited from ChannelAPI
 ChannelAPI (const QString &name, StreamType streamType)
 
virtual ~ChannelAPI ()
 
virtual void setName (const QString &name)
 
virtual const QString & getName () const
 
int getIndexInDeviceSet () const
 
void setIndexInDeviceSet (int indexInDeviceSet)
 
int getDeviceSetIndex () const
 
void setDeviceSetIndex (int deviceSetIndex)
 
DeviceAPIgetDeviceAPI ()
 
void setDeviceAPI (DeviceAPI *deviceAPI)
 
uint64_t getUID () const
 
StreamType getStreamType () const
 

Static Public Member Functions

static int requiredBW (int rfBW)
 

Static Public Attributes

static const QString m_channelIdURI = "sdrangel.channel.bfm"
 
static const QString m_channelId = "BFMDemod"
 

Private Types

enum  RateState { RSInitialFill, RSRunning }
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void applyAudioSampleRate (int sampleRate)
 
void applyChannelSettings (int inputSampleRate, int inputFrequencyOffset, bool force=false)
 
void applySettings (const BFMDemodSettings &settings, bool force=false)
 
void webapiFormatChannelSettings (SWGSDRangel::SWGChannelSettings &response, const BFMDemodSettings &settings)
 
void webapiFormatChannelReport (SWGSDRangel::SWGChannelReport &response)
 
void webapiFormatRDSReport (SWGSDRangel::SWGRDSReport *report)
 
void webapiReverseSendSettings (QList< QString > &channelSettingsKeys, const BFMDemodSettings &settings, bool force)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSinkm_threadedChannelizer
 
DownChannelizerm_channelizer
 
int m_inputSampleRate
 
int m_inputFrequencyOffset
 
BFMDemodSettings m_settings
 
quint32 m_audioSampleRate
 
NCO m_nco
 
Interpolator m_interpolator
 Interpolator between fixed demod bandwidth and audio bandwidth (rational) More...
 
Real m_interpolatorDistance
 
Real m_interpolatorDistanceRemain
 
Interpolator m_interpolatorStereo
 Twin Interpolator for stereo subcarrier. More...
 
Real m_interpolatorStereoDistance
 
Real m_interpolatorStereoDistanceRemain
 
Interpolator m_interpolatorRDS
 Twin Interpolator for stereo subcarrier. More...
 
Real m_interpolatorRDSDistance
 
Real m_interpolatorRDSDistanceRemain
 
Lowpass< Realm_lowpass
 
fftfiltm_rfFilter
 
Real m_squelchLevel
 
int m_squelchState
 
Real m_m1Arg
 
double m_magsq
 

x^-1 real sample

More...
 
double m_magsqSum
 
double m_magsqPeak
 
int m_magsqCount
 
MagSqLevelsStore m_magSqLevelStore
 
AudioVector m_audioBuffer
 
uint m_audioBufferFill
 
BasebandSampleSinkm_sampleSink
 
AudioFifo m_audioFifo
 
SampleVector m_sampleBuffer
 
QMutex m_settingsMutex
 
RDSPhaseLock m_pilotPLL
 
Real m_pilotPLLSamples [4]
 
RDSDemod m_rdsDemod
 
RDSDecoder m_rdsDecoder
 
RDSParser m_rdsParser
 
LowPassFilterRC m_deemphasisFilterX
 
LowPassFilterRC m_deemphasisFilterY
 
Real m_fmExcursion
 
PhaseDiscriminators m_phaseDiscri
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 

Static Private Attributes

static const int filtFftLen = 1024
 
static const Real default_deemphasis = 50.0
 
static const int default_excursion = 750000
 
static const int m_udpBlockSize = 512
 

Additional Inherited Members

- Public Types inherited from ChannelAPI
enum  StreamType { StreamSingleSink, StreamSingleSource, StreamMIMO }
 < This is the same enum as in PluginInterface More...
 
- Protected Slots inherited from BasebandSampleSink
void handleInputMessages ()
 
- Protected Attributes inherited from BasebandSampleSink
MessageQueue m_inputMessageQueue
 Queue for asynchronous inbound communication. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 55 of file bfmdemod.h.

Member Enumeration Documentation

◆ RateState

enum BFMDemod::RateState
private
Enumerator
RSInitialFill 
RSRunning 

Definition at line 220 of file bfmdemod.h.

Constructor & Destructor Documentation

◆ BFMDemod()

BFMDemod::BFMDemod ( DeviceAPI deviceAPI)

Definition at line 55 of file bfmdemod.cpp.

References AudioDeviceManager::addAudioSink(), DeviceAPI::addChannelSink(), DeviceAPI::addChannelSinkAPI(), applyChannelSettings(), applySettings(), LowPassFilterRC::configure(), default_deemphasis, filtFftLen, DSPEngine::getAudioDeviceManager(), BasebandSampleSink::getInputMessageQueue(), AudioDeviceManager::getOutputSampleRate(), DSPEngine::instance(), m_audioBuffer, m_audioBufferFill, m_audioFifo, m_audioSampleRate, m_channelId, m_channelizer, m_deemphasisFilterX, m_deemphasisFilterY, m_deviceAPI, m_fmExcursion, m_inputFrequencyOffset, m_inputSampleRate, m_interpolatorDistance, m_interpolatorDistanceRemain, m_interpolatorRDSDistance, m_interpolatorRDSDistanceRemain, m_interpolatorStereoDistance, m_interpolatorStereoDistanceRemain, m_m1Arg, m_magsq, m_magsqCount, m_magsqPeak, m_magsqSum, m_networkManager, m_phaseDiscri, m_rfFilter, m_sampleSink, m_settings, m_squelchLevel, m_squelchState, m_threadedChannelizer, networkManagerFinished(), and PhaseDiscriminators::setFMScaling().

55  :
57  m_deviceAPI(deviceAPI),
58  m_inputSampleRate(384000),
60  m_audioFifo(250000),
61  m_settingsMutex(QMutex::Recursive),
62  m_pilotPLL(19000/384000, 50/384000, 0.01),
63  m_deemphasisFilterX(default_deemphasis * 48000 * 1.0e-6),
64  m_deemphasisFilterY(default_deemphasis * 48000 * 1.0e-6),
66 {
67  setObjectName(m_channelId);
68 
71 
72  m_magsq = 0.0f;
73  m_magsqSum = 0.0f;
74  m_magsqPeak = 0.0f;
75  m_magsqCount = 0;
76 
77  m_squelchLevel = 0;
78  m_squelchState = 0;
79 
82 
85 
88 
89  m_sampleSink = 0;
90  m_m1Arg = 0;
91 
92  m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, filtFftLen);
93 
97 
98  m_audioBuffer.resize(16384);
100 
102  applySettings(m_settings, true);
103 
104  m_channelizer = new DownChannelizer(this);
108 
109  m_networkManager = new QNetworkAccessManager();
110  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
111 }
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
fftfilt * m_rfFilter
Definition: bfmdemod.h:248
int getOutputSampleRate(int outputDeviceIndex=-1)
Real m_interpolatorRDSDistanceRemain
Definition: bfmdemod.h:245
QMutex m_settingsMutex
Definition: bfmdemod.h:268
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
static const QString m_channelIdURI
Definition: bfmdemod.h:206
quint32 m_audioSampleRate
Definition: bfmdemod.h:232
AudioVector m_audioBuffer
Definition: bfmdemod.h:262
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void setFMScaling(Real fmScaling)
Definition: phasediscri.h:42
void configure(Real timeout)
Definition: filterrc.cpp:32
int m_magsqCount
Definition: bfmdemod.h:259
static const Real default_deemphasis
Definition: bfmdemod.h:279
static const QString m_channelId
Definition: bfmdemod.h:207
LowPassFilterRC m_deemphasisFilterY
Definition: bfmdemod.h:278
double m_magsqPeak
Definition: bfmdemod.h:258
Real m_interpolatorDistanceRemain
Definition: bfmdemod.h:237
DeviceAPI * m_deviceAPI
Definition: bfmdemod.h:225
int m_squelchState
Definition: bfmdemod.h:252
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: bfmdemod.h:226
AudioFifo m_audioFifo
Definition: bfmdemod.h:266
int m_inputSampleRate
Definition: bfmdemod.h:229
double m_magsqSum
Definition: bfmdemod.h:257
static DSPEngine * instance()
Definition: dspengine.cpp:51
LowPassFilterRC m_deemphasisFilterX
Definition: bfmdemod.h:277
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
DownChannelizer * m_channelizer
Definition: bfmdemod.h:227
Real m_m1Arg
Definition: bfmdemod.h:254
int m_inputFrequencyOffset
Definition: bfmdemod.h:230
Real m_fmExcursion
Definition: bfmdemod.h:281
void applySettings(const BFMDemodSettings &settings, bool force=false)
Definition: bfmdemod.cpp:450
uint m_audioBufferFill
Definition: bfmdemod.h:263
Exposes a single sink stream (input, Rx)
Definition: channelapi.h:41
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
Real m_interpolatorRDSDistance
Definition: bfmdemod.h:244
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
static const int filtFftLen
Definition: bfmdemod.h:249
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
Real m_interpolatorStereoDistanceRemain
Definition: bfmdemod.h:241
static const int default_excursion
Definition: bfmdemod.h:282
PhaseDiscriminators m_phaseDiscri
Definition: bfmdemod.h:284
double m_magsq
x^-1 real sample
Definition: bfmdemod.h:256
QNetworkAccessManager * m_networkManager
Definition: bfmdemod.h:288
Real m_interpolatorDistance
Definition: bfmdemod.h:236
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: bfmdemod.cpp:408
Real m_interpolatorStereoDistance
Definition: bfmdemod.h:240
void networkManagerFinished(QNetworkReply *reply)
Definition: bfmdemod.cpp:846
RDSPhaseLock m_pilotPLL
Definition: bfmdemod.h:270
BasebandSampleSink * m_sampleSink
Definition: bfmdemod.h:265
Real m_squelchLevel
Definition: bfmdemod.h:251
+ Here is the call graph for this function:

◆ ~BFMDemod()

BFMDemod::~BFMDemod ( )
virtual

Definition at line 113 of file bfmdemod.cpp.

References DSPEngine::getAudioDeviceManager(), DSPEngine::instance(), m_audioFifo, m_channelizer, m_deviceAPI, m_networkManager, m_rfFilter, m_threadedChannelizer, networkManagerFinished(), AudioDeviceManager::removeAudioSink(), DeviceAPI::removeChannelSink(), and DeviceAPI::removeChannelSinkAPI().

114 {
115  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
116  delete m_networkManager;
117 
119 
122  delete m_threadedChannelizer;
123  delete m_channelizer;
124  delete m_rfFilter;
125 }
fftfilt * m_rfFilter
Definition: bfmdemod.h:248
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
void removeAudioSink(AudioFifo *audioFifo)
Remove the audio sink.
DeviceAPI * m_deviceAPI
Definition: bfmdemod.h:225
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: bfmdemod.h:226
AudioFifo m_audioFifo
Definition: bfmdemod.h:266
static DSPEngine * instance()
Definition: dspengine.cpp:51
DownChannelizer * m_channelizer
Definition: bfmdemod.h:227
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
QNetworkAccessManager * m_networkManager
Definition: bfmdemod.h:288
void networkManagerFinished(QNetworkReply *reply)
Definition: bfmdemod.cpp:846
+ Here is the call graph for this function:

Member Function Documentation

◆ applyAudioSampleRate()

void BFMDemod::applyAudioSampleRate ( int  sampleRate)
private

Definition at line 386 of file bfmdemod.cpp.

References LowPassFilterRC::configure(), Interpolator::create(), default_deemphasis, BFMDemodSettings::m_afBandwidth, m_audioSampleRate, m_deemphasisFilterX, m_deemphasisFilterY, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_interpolatorStereo, m_interpolatorStereoDistance, m_interpolatorStereoDistanceRemain, m_settings, and m_settingsMutex.

Referenced by applySettings(), and handleMessage().

387 {
388  qDebug("BFMDemod::applyAudioSampleRate: %d", sampleRate);
389 
390  m_settingsMutex.lock();
391 
395 
399 
400  m_deemphasisFilterX.configure(default_deemphasis * sampleRate * 1.0e-6);
401  m_deemphasisFilterY.configure(default_deemphasis * sampleRate * 1.0e-6);
402 
403  m_settingsMutex.unlock();
404 
405  m_audioSampleRate = sampleRate;
406 }
QMutex m_settingsMutex
Definition: bfmdemod.h:268
Interpolator m_interpolator
Interpolator between fixed demod bandwidth and audio bandwidth (rational)
Definition: bfmdemod.h:235
quint32 m_audioSampleRate
Definition: bfmdemod.h:232
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
void configure(Real timeout)
Definition: filterrc.cpp:32
static const Real default_deemphasis
Definition: bfmdemod.h:279
LowPassFilterRC m_deemphasisFilterY
Definition: bfmdemod.h:278
Real m_interpolatorDistanceRemain
Definition: bfmdemod.h:237
int m_inputSampleRate
Definition: bfmdemod.h:229
LowPassFilterRC m_deemphasisFilterX
Definition: bfmdemod.h:277
Interpolator m_interpolatorStereo
Twin Interpolator for stereo subcarrier.
Definition: bfmdemod.h:239
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
Real m_interpolatorStereoDistanceRemain
Definition: bfmdemod.h:241
Real m_interpolatorDistance
Definition: bfmdemod.h:236
Real m_interpolatorStereoDistance
Definition: bfmdemod.h:240
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyChannelSettings()

void BFMDemod::applyChannelSettings ( int  inputSampleRate,
int  inputFrequencyOffset,
bool  force = false 
)
private

Definition at line 408 of file bfmdemod.cpp.

References PhaseLock::configure(), Interpolator::create(), fftfilt::create_filter(), BFMDemodSettings::m_afBandwidth, m_audioSampleRate, m_fmExcursion, m_inputFrequencyOffset, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_interpolatorRDS, m_interpolatorRDSDistance, m_interpolatorRDSDistanceRemain, m_interpolatorStereo, m_interpolatorStereoDistance, m_interpolatorStereoDistanceRemain, m_nco, m_phaseDiscri, m_pilotPLL, BFMDemodSettings::m_rfBandwidth, m_rfFilter, m_settings, m_settingsMutex, PhaseDiscriminators::setFMScaling(), and NCO::setFreq().

Referenced by BFMDemod(), handleMessage(), and start().

409 {
410  qDebug() << "BFMDemod::applyChannelSettings:"
411  << " inputSampleRate: " << inputSampleRate
412  << " inputFrequencyOffset: " << inputFrequencyOffset;
413 
414  if((inputFrequencyOffset != m_inputFrequencyOffset) ||
415  (inputSampleRate != m_inputSampleRate) || force)
416  {
417  m_nco.setFreq(-inputFrequencyOffset, inputSampleRate);
418  }
419 
420  if ((inputSampleRate != m_inputSampleRate) || force)
421  {
422  m_pilotPLL.configure(19000.0/inputSampleRate, 50.0/inputSampleRate, 0.01);
423 
424  m_settingsMutex.lock();
425 
426  m_interpolator.create(16, inputSampleRate, m_settings.m_afBandwidth);
428  m_interpolatorDistance = (Real) inputSampleRate / (Real) m_audioSampleRate;
429 
430  m_interpolatorStereo.create(16, inputSampleRate, m_settings.m_afBandwidth);
433 
434  m_interpolatorRDS.create(4, inputSampleRate, 600.0);
435  m_interpolatorRDSDistanceRemain = (Real) inputSampleRate / 250000.0;
436  m_interpolatorRDSDistance = (Real) inputSampleRate / 250000.0;
437 
438  Real lowCut = -(m_settings.m_rfBandwidth / 2.0) / inputSampleRate;
439  Real hiCut = (m_settings.m_rfBandwidth / 2.0) / inputSampleRate;
440  m_rfFilter->create_filter(lowCut, hiCut);
441  m_phaseDiscri.setFMScaling(inputSampleRate / m_fmExcursion);
442 
443  m_settingsMutex.unlock();
444  }
445 
446  m_inputSampleRate = inputSampleRate;
447  m_inputFrequencyOffset = inputFrequencyOffset;
448 }
fftfilt * m_rfFilter
Definition: bfmdemod.h:248
Real m_interpolatorRDSDistanceRemain
Definition: bfmdemod.h:245
QMutex m_settingsMutex
Definition: bfmdemod.h:268
Interpolator m_interpolator
Interpolator between fixed demod bandwidth and audio bandwidth (rational)
Definition: bfmdemod.h:235
quint32 m_audioSampleRate
Definition: bfmdemod.h:232
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
void setFMScaling(Real fmScaling)
Definition: phasediscri.h:42
void configure(Real freq, Real bandwidth, Real minsignal)
Definition: phaselock.cpp:87
Real m_interpolatorDistanceRemain
Definition: bfmdemod.h:237
NCO m_nco
Definition: bfmdemod.h:234
int m_inputSampleRate
Definition: bfmdemod.h:229
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
void setFreq(Real freq, Real sampleRate)
Definition: nco.cpp:49
Interpolator m_interpolatorStereo
Twin Interpolator for stereo subcarrier.
Definition: bfmdemod.h:239
int m_inputFrequencyOffset
Definition: bfmdemod.h:230
Real m_fmExcursion
Definition: bfmdemod.h:281
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
Real m_interpolatorRDSDistance
Definition: bfmdemod.h:244
Real m_interpolatorStereoDistanceRemain
Definition: bfmdemod.h:241
Interpolator m_interpolatorRDS
Twin Interpolator for stereo subcarrier.
Definition: bfmdemod.h:243
PhaseDiscriminators m_phaseDiscri
Definition: bfmdemod.h:284
Real m_interpolatorDistance
Definition: bfmdemod.h:236
Real m_interpolatorStereoDistance
Definition: bfmdemod.h:240
float Real
Definition: dsptypes.h:42
RDSPhaseLock m_pilotPLL
Definition: bfmdemod.h:270
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySettings()

void BFMDemod::applySettings ( const BFMDemodSettings settings,
bool  force = false 
)
private

Definition at line 450 of file bfmdemod.cpp.

References AudioDeviceManager::addAudioSink(), applyAudioSampleRate(), PhaseLock::configure(), Lowpass< Type >::create(), Interpolator::create(), fftfilt::create_filter(), DSPEngine::getAudioDeviceManager(), BasebandSampleSink::getInputMessageQueue(), AudioDeviceManager::getOutputDeviceIndex(), AudioDeviceManager::getOutputSampleRate(), DSPEngine::instance(), BFMDemodSettings::m_afBandwidth, BFMDemodSettings::m_audioDeviceName, m_audioFifo, m_audioSampleRate, BFMDemodSettings::m_audioStereo, m_fmExcursion, BFMDemodSettings::m_inputFrequencyOffset, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_interpolatorRDS, m_interpolatorRDSDistance, m_interpolatorRDSDistanceRemain, m_interpolatorStereo, m_interpolatorStereoDistance, m_interpolatorStereoDistanceRemain, m_lowpass, BFMDemodSettings::m_lsbStereo, m_phaseDiscri, m_pilotPLL, BFMDemodSettings::m_rdsActive, BFMDemodSettings::m_reverseAPIAddress, BFMDemodSettings::m_reverseAPIChannelIndex, BFMDemodSettings::m_reverseAPIDeviceIndex, BFMDemodSettings::m_reverseAPIPort, BFMDemodSettings::m_rfBandwidth, m_rfFilter, m_settings, m_settingsMutex, BFMDemodSettings::m_showPilot, BFMDemodSettings::m_squelch, m_squelchLevel, BFMDemodSettings::m_useReverseAPI, BFMDemodSettings::m_volume, PhaseDiscriminators::setFMScaling(), and webapiReverseSendSettings().

Referenced by BFMDemod(), and handleMessage().

451 {
452  qDebug() << "BFMDemod::applySettings: MsgConfigureBFMDemod:"
453  << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
454  << " m_rfBandwidth: " << settings.m_rfBandwidth
455  << " m_afBandwidth: " << settings.m_afBandwidth
456  << " m_volume: " << settings.m_volume
457  << " m_squelch: " << settings.m_squelch
458  << " m_audioStereo: " << settings.m_audioStereo
459  << " m_lsbStereo: " << settings.m_lsbStereo
460  << " m_showPilot: " << settings.m_showPilot
461  << " m_rdsActive: " << settings.m_rdsActive
462  << " m_audioDeviceName: " << settings.m_audioDeviceName
463  << " m_useReverseAPI: " << settings.m_useReverseAPI
464  << " force: " << force;
465 
466  QList<QString> reverseAPIKeys;
467 
468  if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
469  reverseAPIKeys.append("inputFrequencyOffset");
470  }
471  if ((settings.m_volume != m_settings.m_volume) || force) {
472  reverseAPIKeys.append("volume");
473  }
474  if ((settings.m_audioStereo != m_settings.m_audioStereo) || force) {
475  reverseAPIKeys.append("audioStereo");
476  }
477  if ((settings.m_lsbStereo != m_settings.m_lsbStereo) || force) {
478  reverseAPIKeys.append("lsbStereo");
479  }
480  if ((settings.m_showPilot != m_settings.m_showPilot) || force) {
481  reverseAPIKeys.append("showPilot");
482  }
483  if ((settings.m_rdsActive != m_settings.m_rdsActive) || force) {
484  reverseAPIKeys.append("rdsActive");
485  }
486 
487  if ((settings.m_audioStereo && (settings.m_audioStereo != m_settings.m_audioStereo)) || force)
488  {
490  }
491 
492  if ((settings.m_afBandwidth != m_settings.m_afBandwidth) || force)
493  {
494  reverseAPIKeys.append("afBandwidth");
495  m_settingsMutex.lock();
496 
500 
504 
508 
510 
511  m_settingsMutex.unlock();
512  }
513 
514  if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force)
515  {
516  reverseAPIKeys.append("rfBandwidth");
517  m_settingsMutex.lock();
518  Real lowCut = -(settings.m_rfBandwidth / 2.0) / m_inputSampleRate;
519  Real hiCut = (settings.m_rfBandwidth / 2.0) / m_inputSampleRate;
520  m_rfFilter->create_filter(lowCut, hiCut);
522  m_settingsMutex.unlock();
523  }
524 
525  if ((settings.m_squelch != m_settings.m_squelch) || force)
526  {
527  reverseAPIKeys.append("squelch");
528  m_squelchLevel = std::pow(10.0, settings.m_squelch / 10.0);
529  }
530 
531  if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
532  {
533  reverseAPIKeys.append("audioDeviceName");
535  int audioDeviceIndex = audioDeviceManager->getOutputDeviceIndex(settings.m_audioDeviceName);
536  //qDebug("AMDemod::applySettings: audioDeviceName: %s audioDeviceIndex: %d", qPrintable(settings.m_audioDeviceName), audioDeviceIndex);
537  audioDeviceManager->addAudioSink(&m_audioFifo, getInputMessageQueue(), audioDeviceIndex);
538  uint32_t audioSampleRate = audioDeviceManager->getOutputSampleRate(audioDeviceIndex);
539 
540  if (m_audioSampleRate != audioSampleRate) {
541  applyAudioSampleRate(audioSampleRate);
542  }
543  }
544 
545  if (settings.m_useReverseAPI)
546  {
547  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
552  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
553  }
554 
555  m_settings = settings;
556 }
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
fftfilt * m_rfFilter
Definition: bfmdemod.h:248
QString m_reverseAPIAddress
int getOutputSampleRate(int outputDeviceIndex=-1)
Real m_interpolatorRDSDistanceRemain
Definition: bfmdemod.h:245
QMutex m_settingsMutex
Definition: bfmdemod.h:268
uint16_t m_reverseAPIChannelIndex
Interpolator m_interpolator
Interpolator between fixed demod bandwidth and audio bandwidth (rational)
Definition: bfmdemod.h:235
quint32 m_audioSampleRate
Definition: bfmdemod.h:232
qint64 m_inputFrequencyOffset
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void setFMScaling(Real fmScaling)
Definition: phasediscri.h:42
void create(int nTaps, double sampleRate, double cutoff)
Definition: lowpass.h:15
int getOutputDeviceIndex(const QString &deviceName) const
void configure(Real freq, Real bandwidth, Real minsignal)
Definition: phaselock.cpp:87
Real m_interpolatorDistanceRemain
Definition: bfmdemod.h:237
uint16_t m_reverseAPIDeviceIndex
unsigned int uint32_t
Definition: rtptypes_win.h:46
void applyAudioSampleRate(int sampleRate)
Definition: bfmdemod.cpp:386
AudioFifo m_audioFifo
Definition: bfmdemod.h:266
int m_inputSampleRate
Definition: bfmdemod.h:229
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
static DSPEngine * instance()
Definition: dspengine.cpp:51
uint16_t m_reverseAPIPort
Interpolator m_interpolatorStereo
Twin Interpolator for stereo subcarrier.
Definition: bfmdemod.h:239
Real m_fmExcursion
Definition: bfmdemod.h:281
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
Real m_interpolatorRDSDistance
Definition: bfmdemod.h:244
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
Real m_interpolatorStereoDistanceRemain
Definition: bfmdemod.h:241
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const BFMDemodSettings &settings, bool force)
Definition: bfmdemod.cpp:778
Lowpass< Real > m_lowpass
Definition: bfmdemod.h:247
Interpolator m_interpolatorRDS
Twin Interpolator for stereo subcarrier.
Definition: bfmdemod.h:243
PhaseDiscriminators m_phaseDiscri
Definition: bfmdemod.h:284
Real m_interpolatorDistance
Definition: bfmdemod.h:236
Real m_interpolatorStereoDistance
Definition: bfmdemod.h:240
float Real
Definition: dsptypes.h:42
RDSPhaseLock m_pilotPLL
Definition: bfmdemod.h:270
Real m_squelchLevel
Definition: bfmdemod.h:251
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

bool BFMDemod::deserialize ( const QByteArray &  data)
virtual

Implements ChannelAPI.

Definition at line 563 of file bfmdemod.cpp.

References BFMDemod::MsgConfigureBFMDemod::create(), BFMDemodSettings::deserialize(), BasebandSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and BFMDemodSettings::resetToDefaults().

564 {
565  if (m_settings.deserialize(data))
566  {
567  MsgConfigureBFMDemod *msg = MsgConfigureBFMDemod::create(m_settings, true);
569  return true;
570  }
571  else
572  {
574  MsgConfigureBFMDemod *msg = MsgConfigureBFMDemod::create(m_settings, true);
576  return false;
577  }
578 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
bool deserialize(const QByteArray &data)
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
static MsgConfigureBFMDemod * create(const BFMDemodSettings &settings, bool force)
Definition: bfmdemod.h:65
+ Here is the call graph for this function:

◆ destroy()

virtual void BFMDemod::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 126 of file bfmdemod.h.

126 { delete this; }

◆ feed()

void BFMDemod::feed ( const SampleVector::const_iterator &  begin,
const SampleVector::const_iterator &  end,
bool  po 
)
virtual

Implements BasebandSampleSink.

Definition at line 127 of file bfmdemod.cpp.

References cos(), Interpolator::decimate(), BasebandSampleSink::feed(), RDSDecoder::frameSync(), RDSDecoder::getGroup(), i, m_audioBuffer, m_audioBufferFill, m_audioFifo, BFMDemodSettings::m_audioStereo, m_deemphasisFilterX, m_deemphasisFilterY, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_interpolatorRDS, m_interpolatorRDSDistance, m_interpolatorRDSDistanceRemain, m_interpolatorStereo, m_interpolatorStereoDistance, m_interpolatorStereoDistanceRemain, BFMDemodSettings::m_lsbStereo, m_magsqCount, m_magsqPeak, m_magsqSum, m_nco, m_phaseDiscri, m_pilotPLL, m_pilotPLLSamples, BFMDemodSettings::m_rdsActive, m_rdsDecoder, m_rdsDemod, m_rdsParser, BFMDemodSettings::m_rfBandwidth, m_rfFilter, m_sampleBuffer, m_sampleSink, m_settings, m_settingsMutex, BFMDemodSettings::m_showPilot, m_squelchLevel, m_squelchState, BFMDemodSettings::m_volume, NCO::nextIQ(), RDSParser::parseGroup(), PhaseDiscriminators::phaseDiscriminator(), RDSDemod::process(), LowPassFilterRC::process(), PhaseLock::process(), fftfilt::runFilt(), SDR_RX_SCALEF, and AudioFifo::write().

128 {
129  (void) firstOfBurst;
130  Complex ci, cs, cr;
131  fftfilt::cmplx *rf;
132  int rf_out;
133  double msq;
134  Real demod;
135 
136  m_sampleBuffer.clear();
137 
138  m_settingsMutex.lock();
139 
140  for (SampleVector::const_iterator it = begin; it != end; ++it)
141  {
142  Complex c(it->real() / SDR_RX_SCALEF, it->imag() / SDR_RX_SCALEF);
143  c *= m_nco.nextIQ();
144 
145  rf_out = m_rfFilter->runFilt(c, &rf); // filter RF before demod
146 
147  for (int i =0 ; i <rf_out; i++)
148  {
149  msq = rf[i].real()*rf[i].real() + rf[i].imag()*rf[i].imag();
150  m_magsqSum += msq;
151 
152  if (msq > m_magsqPeak) {
153  m_magsqPeak = msq;
154  }
155 
156  m_magsqCount++;
157 
158  if (msq >= m_squelchLevel)
159  {
160  if (m_squelchState < m_settings.m_rfBandwidth / 10) { // twice attack and decay rate
161  m_squelchState++;
162  }
163  }
164  else
165  {
166  if (m_squelchState > 0) {
167  m_squelchState--;
168  }
169  }
170 
171  if (m_squelchState > m_settings.m_rfBandwidth / 20) { // squelch open
172  demod = m_phaseDiscri.phaseDiscriminator(rf[i]);
173  } else {
174  demod = 0;
175  }
176 
177  if (!m_settings.m_showPilot) {
178  m_sampleBuffer.push_back(Sample(demod * SDR_RX_SCALEF, 0.0));
179  }
180 
182  {
183  //Complex r(demod * 2.0 * std::cos(3.0 * m_pilotPLLSamples[3]), 0.0);
184  Complex r(demod * 2.0 * std::cos(3.0 * m_pilotPLLSamples[3]), 0.0);
185 
187  {
188  bool bit;
189 
190  if (m_rdsDemod.process(cr.real(), bit))
191  {
192  if (m_rdsDecoder.frameSync(bit)) {
194  }
195  }
196 
198  }
199  }
200 
201  Real sampleStereo = 0.0f;
202 
203  // Process stereo if stereo mode is selected
204 
206  {
208 
209  if (m_settings.m_showPilot) {
210  m_sampleBuffer.push_back(Sample(m_pilotPLLSamples[1] * SDR_RX_SCALEF, 0.0)); // debug 38 kHz pilot
211  }
212 
214  {
215  // 1.17 * 0.7 = 0.819
216  Complex s(demod * m_pilotPLLSamples[1], demod * m_pilotPLLSamples[2]);
217 
219  {
220  sampleStereo = cs.real() + cs.imag();
222  }
223  }
224  else
225  {
226  Complex s(demod * 1.17 * m_pilotPLLSamples[1], 0);
227 
229  {
230  sampleStereo = cs.real();
232  }
233  }
234  }
235 
236  Complex e(demod, 0);
237 
239  {
241  {
242  Real deemph_l, deemph_r; // Pre-emphasis is applied on each channel before multiplexing
243  m_deemphasisFilterX.process(ci.real() + sampleStereo, deemph_l);
244  m_deemphasisFilterY.process(ci.real() - sampleStereo, deemph_r);
245  m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_settings.m_volume);
246  m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_settings.m_volume);
247  }
248  else
249  {
250  Real deemph;
251  m_deemphasisFilterX.process(ci.real(), deemph);
252  quint16 sample = (qint16)(deemph * (1<<12) * m_settings.m_volume);
253  m_audioBuffer[m_audioBufferFill].l = sample;
254  m_audioBuffer[m_audioBufferFill].r = sample;
255  }
256 
258 
259  if (m_audioBufferFill >= m_audioBuffer.size())
260  {
261  uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
262 
263  if(res != m_audioBufferFill) {
264  qDebug("BFMDemod::feed: %u/%u audio samples written", res, m_audioBufferFill);
265  }
266 
267  m_audioBufferFill = 0;
268  }
269 
271  }
272  }
273  }
274 
275  if (m_audioBufferFill > 0)
276  {
277  uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
278 
279  if (res != m_audioBufferFill) {
280  qDebug("BFMDemod::feed: %u/%u tail samples written", res, m_audioBufferFill);
281  }
282 
283  m_audioBufferFill = 0;
284  }
285 
286  if (m_sampleSink != 0) {
287  m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
288  }
289 
290  m_sampleBuffer.clear();
291 
292  m_settingsMutex.unlock();
293 }
fftfilt * m_rfFilter
Definition: bfmdemod.h:248
bool process(Real rdsSample, bool &bit)
Definition: rdsdemod.cpp:75
Complex nextIQ()
Return next complex sample.
Definition: nco.cpp:61
bool decimate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:38
Real m_interpolatorRDSDistanceRemain
Definition: bfmdemod.h:245
Real m_pilotPLLSamples[4]
Definition: bfmdemod.h:271
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
void parseGroup(unsigned int *group)
Definition: rdsparser.cpp:374
QMutex m_settingsMutex
Definition: bfmdemod.h:268
Interpolator m_interpolator
Interpolator between fixed demod bandwidth and audio bandwidth (rational)
Definition: bfmdemod.h:235
AudioVector m_audioBuffer
Definition: bfmdemod.h:262
unsigned int * getGroup()
Definition: rdsdecoder.h:29
int m_magsqCount
Definition: bfmdemod.h:259
void process(const Real &sample_in, Real &sample_out)
Definition: filterrc.cpp:45
int runFilt(const cmplx &in, cmplx **out)
Definition: fftfilt.cpp:260
LowPassFilterRC m_deemphasisFilterY
Definition: bfmdemod.h:278
double m_magsqPeak
Definition: bfmdemod.h:258
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool positiveOnly)=0
Real m_interpolatorDistanceRemain
Definition: bfmdemod.h:237
int m_squelchState
Definition: bfmdemod.h:252
std::complex< float > cmplx
Definition: fftfilt.h:21
#define SDR_RX_SCALEF
Definition: dsptypes.h:33
NCO m_nco
Definition: bfmdemod.h:234
AudioFifo m_audioFifo
Definition: bfmdemod.h:266
double m_magsqSum
Definition: bfmdemod.h:257
SampleVector m_sampleBuffer
Definition: bfmdemod.h:267
LowPassFilterRC m_deemphasisFilterX
Definition: bfmdemod.h:277
void process(const std::vector< Real > &samples_in, std::vector< Real > &samples_out)
Definition: phaselock.cpp:148
int32_t i
Definition: decimators.h:244
Real phaseDiscriminator(const Complex &sample)
Definition: phasediscri.h:51
Interpolator m_interpolatorStereo
Twin Interpolator for stereo subcarrier.
Definition: bfmdemod.h:239
RDSParser m_rdsParser
Definition: bfmdemod.h:275
uint m_audioBufferFill
Definition: bfmdemod.h:263
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
Real m_interpolatorRDSDistance
Definition: bfmdemod.h:244
Real m_interpolatorStereoDistanceRemain
Definition: bfmdemod.h:241
bool frameSync(bool bit)
Definition: rdsdecoder.cpp:51
Interpolator m_interpolatorRDS
Twin Interpolator for stereo subcarrier.
Definition: bfmdemod.h:243
PhaseDiscriminators m_phaseDiscri
Definition: bfmdemod.h:284
Real m_interpolatorDistance
Definition: bfmdemod.h:236
RDSDemod m_rdsDemod
Definition: bfmdemod.h:273
std::complex< Real > Complex
Definition: dsptypes.h:43
Real m_interpolatorStereoDistance
Definition: bfmdemod.h:240
float Real
Definition: dsptypes.h:42
RDSDecoder m_rdsDecoder
Definition: bfmdemod.h:274
RDSPhaseLock m_pilotPLL
Definition: bfmdemod.h:270
BasebandSampleSink * m_sampleSink
Definition: bfmdemod.h:265
uint32_t write(const quint8 *data, uint32_t numSamples)
Definition: audiofifo.cpp:66
Real m_squelchLevel
Definition: bfmdemod.h:251
+ Here is the call graph for this function:

◆ getCenterFrequency()

virtual qint64 BFMDemod::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 137 of file bfmdemod.h.

qint64 m_inputFrequencyOffset
BFMDemodSettings m_settings
Definition: bfmdemod.h:231

◆ getDecoderQua()

Real BFMDemod::getDecoderQua ( ) const
inline

Definition at line 157 of file bfmdemod.h.

Referenced by BFMDemodGUI::rdsUpdate(), and webapiFormatRDSReport().

157 { return m_rdsDecoder.m_qua; }
float m_qua
Definition: rdsdecoder.h:32
RDSDecoder m_rdsDecoder
Definition: bfmdemod.h:274
+ Here is the caller graph for this function:

◆ getDecoderSynced()

bool BFMDemod::getDecoderSynced ( ) const
inline

Definition at line 158 of file bfmdemod.h.

Referenced by BFMDemodGUI::rdsUpdate().

158 { return m_rdsDecoder.synced(); }
bool synced() const
Definition: rdsdecoder.h:30
RDSDecoder m_rdsDecoder
Definition: bfmdemod.h:274
+ Here is the caller graph for this function:

◆ getDemodAcc()

Real BFMDemod::getDemodAcc ( ) const
inline

Definition at line 159 of file bfmdemod.h.

Referenced by BFMDemodGUI::rdsUpdate(), and webapiFormatRDSReport().

159 { return m_rdsDemod.m_report.acc; }
struct RDSDemod::@1 m_report
Real acc
Definition: rdsdemod.h:39
RDSDemod m_rdsDemod
Definition: bfmdemod.h:273
+ Here is the caller graph for this function:

◆ getDemodFclk()

Real BFMDemod::getDemodFclk ( ) const
inline

Definition at line 161 of file bfmdemod.h.

Referenced by BFMDemodGUI::rdsUpdate(), and webapiFormatRDSReport().

161 { return m_rdsDemod.m_report.fclk; }
Real fclk
Definition: rdsdemod.h:41
struct RDSDemod::@1 m_report
RDSDemod m_rdsDemod
Definition: bfmdemod.h:273
+ Here is the caller graph for this function:

◆ getDemodQua()

Real BFMDemod::getDemodQua ( ) const
inline

Definition at line 160 of file bfmdemod.h.

Referenced by BFMDemodGUI::rdsUpdate(), and webapiFormatRDSReport().

160 { return m_rdsDemod.m_report.qua; }
struct RDSDemod::@1 m_report
Real qua
Definition: rdsdemod.h:40
RDSDemod m_rdsDemod
Definition: bfmdemod.h:273
+ Here is the caller graph for this function:

◆ getIdentifier()

virtual void BFMDemod::getIdentifier ( QString &  id)
inlinevirtual

Implements ChannelAPI.

Definition at line 135 of file bfmdemod.h.

135 { id = objectName(); }

◆ getMagSq()

double BFMDemod::getMagSq ( ) const
inline

Definition at line 152 of file bfmdemod.h.

152 { return m_magsq; }
double m_magsq
x^-1 real sample
Definition: bfmdemod.h:256

◆ getMagSqLevels()

void BFMDemod::getMagSqLevels ( double &  avg,
double &  peak,
int &  nbSamples 
)
inline

Definition at line 163 of file bfmdemod.h.

Referenced by BFMDemodGUI::tick(), and webapiFormatChannelReport().

164  {
165  if (m_magsqCount > 0)
166  {
170  }
171 
174  nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
175 
176  m_magsqSum = 0.0f;
177  m_magsqPeak = 0.0f;
178  m_magsqCount = 0;
179  }
MagSqLevelsStore m_magSqLevelStore
Definition: bfmdemod.h:260
int m_magsqCount
Definition: bfmdemod.h:259
double m_magsqPeak
Definition: bfmdemod.h:258
double m_magsqSum
Definition: bfmdemod.h:257
double m_magsq
x^-1 real sample
Definition: bfmdemod.h:256
+ Here is the caller graph for this function:

◆ getNbSinkStreams()

virtual int BFMDemod::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 142 of file bfmdemod.h.

142 { return 1; }

◆ getNbSourceStreams()

virtual int BFMDemod::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 143 of file bfmdemod.h.

143 { return 0; }

◆ getPilotLevel()

Real BFMDemod::getPilotLevel ( ) const
inline

Definition at line 155 of file bfmdemod.h.

Referenced by BFMDemodGUI::tick(), and webapiFormatChannelReport().

155 { return m_pilotPLL.get_pilot_level(); }
Real get_pilot_level() const
Definition: phaselock.h:86
RDSPhaseLock m_pilotPLL
Definition: bfmdemod.h:270
+ Here is the caller graph for this function:

◆ getPilotLock()

bool BFMDemod::getPilotLock ( ) const
inline

Definition at line 154 of file bfmdemod.h.

Referenced by BFMDemodGUI::tick(), and webapiFormatChannelReport().

154 { return m_pilotPLL.locked(); }
bool locked() const
Definition: phaselock.h:80
RDSPhaseLock m_pilotPLL
Definition: bfmdemod.h:270
+ Here is the caller graph for this function:

◆ getRDSParser()

RDSParser& BFMDemod::getRDSParser ( )
inline

◆ getSampleRate()

int BFMDemod::getSampleRate ( ) const
inline

Definition at line 129 of file bfmdemod.h.

Referenced by handleMessage().

129 { return m_inputSampleRate; }
int m_inputSampleRate
Definition: bfmdemod.h:229
+ Here is the caller graph for this function:

◆ getStreamCenterFrequency()

virtual qint64 BFMDemod::getStreamCenterFrequency ( int  streamIndex,
bool  sinkElseSource 
) const
inlinevirtual

Implements ChannelAPI.

Definition at line 145 of file bfmdemod.h.

146  {
147  (void) streamIndex;
148  (void) sinkElseSource;
150  }
qint64 m_inputFrequencyOffset
BFMDemodSettings m_settings
Definition: bfmdemod.h:231

◆ getTitle()

virtual void BFMDemod::getTitle ( QString &  title)
inlinevirtual

Implements ChannelAPI.

Definition at line 136 of file bfmdemod.h.

136 { title = m_settings.m_title; }
BFMDemodSettings m_settings
Definition: bfmdemod.h:231

◆ handleMessage()

bool BFMDemod::handleMessage ( const Message cmd)
virtual

Processing of a message. Returns true if message has actually been processed.

Implements BasebandSampleSink.

Definition at line 307 of file bfmdemod.cpp.

References applyAudioSampleRate(), applyChannelSettings(), applySettings(), DownChannelizer::configure(), BFMDemod::MsgReportChannelSampleRateChanged::create(), BFMDemod::MsgConfigureChannelizer::getCenterFrequency(), BFMDemod::MsgConfigureBFMDemod::getForce(), DownChannelizer::MsgChannelizerNotification::getFrequencyOffset(), Message::getIdentifier(), BasebandSampleSink::getInputMessageQueue(), BasebandSampleSink::getMessageQueueToGUI(), DownChannelizer::MsgChannelizerNotification::getSampleRate(), BFMDemod::MsgConfigureChannelizer::getSampleRate(), getSampleRate(), DSPConfigureAudio::getSampleRate(), BFMDemod::MsgConfigureBFMDemod::getSettings(), BasebandSampleSink::handleMessage(), m_audioSampleRate, m_channelizer, m_sampleSink, Message::match(), and MessageQueue::push().

308 {
310  {
312 
313  qDebug() << "BFMDemod::handleMessage: MsgChannelizerNotification:"
314  << " inputSampleRate: " << notif.getSampleRate()
315  << " inputFrequencyOffset: " << notif.getFrequencyOffset();
316 
318 
319  if (getMessageQueueToGUI())
320  {
321  MsgReportChannelSampleRateChanged *msg = MsgReportChannelSampleRateChanged::create(getSampleRate());
322  getMessageQueueToGUI()->push(msg);
323  }
324 
325  return true;
326  }
327  else if (MsgConfigureChannelizer::match(cmd))
328  {
329  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
330 
331  qDebug() << "BFMDemod::handleMessage: MsgConfigureChannelizer: sampleRate: " << cfg.getSampleRate()
332  << " centerFrequency: " << cfg.getCenterFrequency();
333 
335  cfg.getSampleRate(),
336  cfg.getCenterFrequency());
337 
338  return true;
339  }
340  else if (MsgConfigureBFMDemod::match(cmd))
341  {
342  MsgConfigureBFMDemod& cfg = (MsgConfigureBFMDemod&) cmd;
343  qDebug() << "BFMDemod::handleMessage: MsgConfigureBFMDemod";
344 
345  applySettings(cfg.getSettings(), cfg.getForce());
346 
347  return true;
348  }
349  else if (DSPConfigureAudio::match(cmd))
350  {
351  DSPConfigureAudio& cfg = (DSPConfigureAudio&) cmd;
352  uint32_t sampleRate = cfg.getSampleRate();
353 
354  qDebug() << "BFMDemod::handleMessage: DSPConfigureAudio:"
355  << " sampleRate: " << sampleRate;
356 
357  if (sampleRate != m_audioSampleRate) {
358  applyAudioSampleRate(sampleRate);
359  }
360 
361  return true;
362  }
364  {
365  return true;
366  }
367  else if (DSPSignalNotification::match(cmd))
368  {
369  return true;
370  }
371  else
372  {
373  qDebug() << "BFMDemod::handleMessage: passed: " << cmd.getIdentifier();
374 
375  if (m_sampleSink != 0)
376  {
377  return m_sampleSink->handleMessage(cmd);
378  }
379  else
380  {
381  return false;
382  }
383  }
384 }
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
quint32 m_audioSampleRate
Definition: bfmdemod.h:232
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
static MsgReportChannelSampleRateChanged * create(int sampleRate)
Definition: bfmdemod.h:110
unsigned int uint32_t
Definition: rtptypes_win.h:46
void applyAudioSampleRate(int sampleRate)
Definition: bfmdemod.cpp:386
virtual bool handleMessage(const Message &cmd)=0
Processing of a message. Returns true if message has actually been processed.
int getSampleRate() const
Definition: dspcommands.h:390
DownChannelizer * m_channelizer
Definition: bfmdemod.h:227
static bool match(const Message *message)
Definition: message.cpp:45
MessageQueue * getMessageQueueToGUI()
void applySettings(const BFMDemodSettings &settings, bool force=false)
Definition: bfmdemod.cpp:450
virtual const char * getIdentifier() const
Definition: message.cpp:35
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: bfmdemod.cpp:408
int getSampleRate() const
Definition: bfmdemod.h:129
BasebandSampleSink * m_sampleSink
Definition: bfmdemod.h:265
+ Here is the call graph for this function:

◆ networkManagerFinished

void BFMDemod::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 846 of file bfmdemod.cpp.

Referenced by BFMDemod(), and ~BFMDemod().

847 {
848  QNetworkReply::NetworkError replyError = reply->error();
849 
850  if (replyError)
851  {
852  qWarning() << "BFMDemod::networkManagerFinished:"
853  << " error(" << (int) replyError
854  << "): " << replyError
855  << ": " << reply->errorString();
856  return;
857  }
858 
859  QString answer = reply->readAll();
860  answer.chop(1); // remove last \n
861  qDebug("BFMDemod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
862 }
+ Here is the caller graph for this function:

◆ requiredBW()

static int BFMDemod::requiredBW ( int  rfBW)
inlinestatic

Definition at line 197 of file bfmdemod.h.

Referenced by BFMDemodGUI::applySettings(), and webapiSettingsPutPatch().

198  {
199  if (rfBW <= 48000) {
200  return 48000;
201  } else {
202  return (3*rfBW)/2;
203  }
204  }
+ Here is the caller graph for this function:

◆ serialize()

QByteArray BFMDemod::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 558 of file bfmdemod.cpp.

References m_settings, and BFMDemodSettings::serialize().

559 {
560  return m_settings.serialize();
561 }
QByteArray serialize() const
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
+ Here is the call graph for this function:

◆ setSampleSink()

void BFMDemod::setSampleSink ( BasebandSampleSink sampleSink)
inline

Definition at line 127 of file bfmdemod.h.

Referenced by BFMDemodGUI::BFMDemodGUI().

127 { m_sampleSink = sampleSink; }
BasebandSampleSink * m_sampleSink
Definition: bfmdemod.h:265
+ Here is the caller graph for this function:

◆ start()

void BFMDemod::start ( )
virtual

Implements BasebandSampleSink.

Definition at line 295 of file bfmdemod.cpp.

References applyChannelSettings(), AudioFifo::clear(), m_audioFifo, m_inputFrequencyOffset, m_inputSampleRate, m_phaseDiscri, m_squelchState, and PhaseDiscriminators::reset().

296 {
297  m_squelchState = 0;
298  m_audioFifo.clear();
301 }
void clear()
Definition: audiofifo.cpp:156
int m_squelchState
Definition: bfmdemod.h:252
AudioFifo m_audioFifo
Definition: bfmdemod.h:266
int m_inputSampleRate
Definition: bfmdemod.h:229
int m_inputFrequencyOffset
Definition: bfmdemod.h:230
PhaseDiscriminators m_phaseDiscri
Definition: bfmdemod.h:284
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: bfmdemod.cpp:408
+ Here is the call graph for this function:

◆ stop()

void BFMDemod::stop ( )
virtual

Implements BasebandSampleSink.

Definition at line 303 of file bfmdemod.cpp.

304 {
305 }

◆ webapiFormatChannelReport()

void BFMDemod::webapiFormatChannelReport ( SWGSDRangel::SWGChannelReport response)
private

Definition at line 726 of file bfmdemod.cpp.

References CalcDb::dbPower(), SWGSDRangel::SWGChannelReport::getBfmDemodReport(), getMagSqLevels(), getPilotLevel(), getPilotLock(), SWGSDRangel::SWGBFMDemodReport::getRdsReport(), m_audioSampleRate, m_inputSampleRate, BFMDemodSettings::m_rdsActive, m_settings, m_squelchState, SWGSDRangel::SWGBFMDemodReport::setAudioSampleRate(), SWGSDRangel::SWGBFMDemodReport::setChannelPowerDb(), SWGSDRangel::SWGBFMDemodReport::setChannelSampleRate(), SWGSDRangel::SWGBFMDemodReport::setPilotLocked(), SWGSDRangel::SWGBFMDemodReport::setPilotPowerDb(), SWGSDRangel::SWGBFMDemodReport::setRdsReport(), SWGSDRangel::SWGBFMDemodReport::setSquelch(), and webapiFormatRDSReport().

Referenced by webapiReportGet().

727 {
728  double magsqAvg, magsqPeak;
729  int nbMagsqSamples;
730  getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
731 
732  response.getBfmDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg));
733  response.getBfmDemodReport()->setSquelch(m_squelchState > 0 ? 1 : 0);
736  response.getBfmDemodReport()->setPilotLocked(getPilotLock() ? 1 : 0);
738 
740  {
743  }
744  else
745  {
746  response.getBfmDemodReport()->setRdsReport(0);
747  }
748 }
void webapiFormatRDSReport(SWGSDRangel::SWGRDSReport *report)
Definition: bfmdemod.cpp:750
SWGBFMDemodReport * getBfmDemodReport()
static double dbPower(double magsq, double floor=1e-12)
Definition: db.cpp:22
void setChannelSampleRate(qint32 channel_sample_rate)
quint32 m_audioSampleRate
Definition: bfmdemod.h:232
int m_squelchState
Definition: bfmdemod.h:252
int m_inputSampleRate
Definition: bfmdemod.h:229
void setAudioSampleRate(qint32 audio_sample_rate)
void setPilotPowerDb(float pilot_power_db)
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
void setChannelPowerDb(float channel_power_db)
void setPilotLocked(qint32 pilot_locked)
Real getPilotLevel() const
Definition: bfmdemod.h:155
void getMagSqLevels(double &avg, double &peak, int &nbSamples)
Definition: bfmdemod.h:163
void setRdsReport(SWGRDSReport *rds_report)
bool getPilotLock() const
Definition: bfmdemod.h:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatChannelSettings()

void BFMDemod::webapiFormatChannelSettings ( SWGSDRangel::SWGChannelSettings response,
const BFMDemodSettings settings 
)
private

Definition at line 688 of file bfmdemod.cpp.

References SWGSDRangel::SWGBFMDemodSettings::getAudioDeviceName(), SWGSDRangel::SWGChannelSettings::getBfmDemodSettings(), SWGSDRangel::SWGBFMDemodSettings::getReverseApiAddress(), SWGSDRangel::SWGBFMDemodSettings::getTitle(), BFMDemodSettings::m_afBandwidth, BFMDemodSettings::m_audioDeviceName, BFMDemodSettings::m_audioStereo, BFMDemodSettings::m_inputFrequencyOffset, BFMDemodSettings::m_lsbStereo, BFMDemodSettings::m_rdsActive, BFMDemodSettings::m_reverseAPIAddress, BFMDemodSettings::m_reverseAPIChannelIndex, BFMDemodSettings::m_reverseAPIDeviceIndex, BFMDemodSettings::m_reverseAPIPort, BFMDemodSettings::m_rfBandwidth, BFMDemodSettings::m_rgbColor, BFMDemodSettings::m_showPilot, BFMDemodSettings::m_squelch, BFMDemodSettings::m_title, BFMDemodSettings::m_useReverseAPI, BFMDemodSettings::m_volume, SWGSDRangel::SWGBFMDemodSettings::setAfBandwidth(), SWGSDRangel::SWGBFMDemodSettings::setAudioDeviceName(), SWGSDRangel::SWGBFMDemodSettings::setAudioStereo(), SWGSDRangel::SWGBFMDemodSettings::setInputFrequencyOffset(), SWGSDRangel::SWGBFMDemodSettings::setLsbStereo(), SWGSDRangel::SWGBFMDemodSettings::setRdsActive(), SWGSDRangel::SWGBFMDemodSettings::setReverseApiAddress(), SWGSDRangel::SWGBFMDemodSettings::setReverseApiChannelIndex(), SWGSDRangel::SWGBFMDemodSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGBFMDemodSettings::setReverseApiPort(), SWGSDRangel::SWGBFMDemodSettings::setRfBandwidth(), SWGSDRangel::SWGBFMDemodSettings::setRgbColor(), SWGSDRangel::SWGBFMDemodSettings::setShowPilot(), SWGSDRangel::SWGBFMDemodSettings::setSquelch(), SWGSDRangel::SWGBFMDemodSettings::setTitle(), SWGSDRangel::SWGBFMDemodSettings::setUseReverseApi(), and SWGSDRangel::SWGBFMDemodSettings::setVolume().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

689 {
691  response.getBfmDemodSettings()->setRfBandwidth(settings.m_rfBandwidth);
692  response.getBfmDemodSettings()->setAfBandwidth(settings.m_afBandwidth);
693  response.getBfmDemodSettings()->setVolume(settings.m_volume);
694  response.getBfmDemodSettings()->setSquelch(settings.m_squelch);
695  response.getBfmDemodSettings()->setAudioStereo(settings.m_audioStereo ? 1 : 0);
696  response.getBfmDemodSettings()->setLsbStereo(settings.m_lsbStereo ? 1 : 0);
697  response.getBfmDemodSettings()->setShowPilot(settings.m_showPilot ? 1 : 0);
698  response.getBfmDemodSettings()->setRdsActive(settings.m_rdsActive ? 1 : 0);
699  response.getBfmDemodSettings()->setRgbColor(settings.m_rgbColor);
700 
701  if (response.getBfmDemodSettings()->getTitle()) {
702  *response.getBfmDemodSettings()->getTitle() = settings.m_title;
703  } else {
704  response.getBfmDemodSettings()->setTitle(new QString(settings.m_title));
705  }
706 
707  if (response.getBfmDemodSettings()->getAudioDeviceName()) {
708  *response.getBfmDemodSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
709  } else {
710  response.getBfmDemodSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
711  }
712 
713  response.getBfmDemodSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
714 
715  if (response.getBfmDemodSettings()->getReverseApiAddress()) {
717  } else {
718  response.getBfmDemodSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
719  }
720 
724 }
QString m_reverseAPIAddress
void setReverseApiPort(qint32 reverse_api_port)
void setUseReverseApi(qint32 use_reverse_api)
uint16_t m_reverseAPIChannelIndex
qint64 m_inputFrequencyOffset
void setAudioDeviceName(QString *audio_device_name)
uint16_t m_reverseAPIDeviceIndex
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
SWGBFMDemodSettings * getBfmDemodSettings()
uint16_t m_reverseAPIPort
void setReverseApiAddress(QString *reverse_api_address)
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setAudioStereo(qint32 audio_stereo)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setAfBandwidth(float af_bandwidth)
void setRfBandwidth(float rf_bandwidth)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatRDSReport()

void BFMDemod::webapiFormatRDSReport ( SWGSDRangel::SWGRDSReport report)
private

Definition at line 750 of file bfmdemod.cpp.

References CalcDb::dbPower(), SWGSDRangel::SWGRDSReport::getAltFrequencies(), getDecoderQua(), getDemodAcc(), getDemodFclk(), getDemodQua(), getRDSParser(), RDSParser::m_g0_alt_freq, SWGSDRangel::SWGRDSReport::setAltFrequencies(), SWGSDRangel::SWGRDSReport::setDecodStatus(), SWGSDRangel::SWGRDSReport::setDemodStatus(), SWGSDRangel::SWGRDSReport::setMonoStereo(), SWGSDRangel::SWGRDSReport::setMusicSpeech(), SWGSDRangel::SWGRDSReport::setPiCoverage(), SWGSDRangel::SWGRDSReport::setPid(), SWGSDRangel::SWGRDSReport::setPiType(), SWGSDRangel::SWGRDSReport::setProgServiceName(), SWGSDRangel::SWGRDSReport::setRadioText(), SWGSDRangel::SWGRDSReport::setRdsDemodAccumDb(), SWGSDRangel::SWGRDSReport::setRdsDemodFrequency(), and SWGSDRangel::SWGRDSReport::setTime().

Referenced by webapiFormatChannelReport().

751 {
752  report->setDemodStatus(round(getDemodQua()));
753  report->setDecodStatus(round(getDecoderQua()));
754  report->setRdsDemodAccumDb(CalcDb::dbPower(std::fabs(getDemodAcc())));
756  report->setPid(new QString(str(boost::format("%04X") % getRDSParser().m_pi_program_identification).c_str()));
757  report->setPiType(new QString(getRDSParser().pty_table[getRDSParser().m_pi_program_type].c_str()));
758  report->setPiCoverage(new QString(getRDSParser().coverage_area_codes[getRDSParser().m_pi_area_coverage_index].c_str()));
759  report->setProgServiceName(new QString(getRDSParser().m_g0_program_service_name));
760  report->setMusicSpeech(new QString((getRDSParser().m_g0_music_speech ? "Music" : "Speech")));
761  report->setMonoStereo(new QString((getRDSParser().m_g0_mono_stereo ? "Mono" : "Stereo")));
762  report->setRadioText(new QString(getRDSParser().m_g2_radiotext));
763  std::string time = str(boost::format("%4i-%02i-%02i %02i:%02i (%+.1fh)")\
764  % (1900 + getRDSParser().m_g4_year) % getRDSParser().m_g4_month % getRDSParser().m_g4_day % getRDSParser().m_g4_hours % getRDSParser().m_g4_minutes % getRDSParser().m_g4_local_time_offset);
765  report->setTime(new QString(time.c_str()));
766  report->setAltFrequencies(new QList<SWGSDRangel::SWGRDSReport_altFrequencies*>);
767 
768  for (std::set<double>::iterator it = getRDSParser().m_g0_alt_freq.begin(); it != getRDSParser().m_g0_alt_freq.end(); ++it)
769  {
770  if (*it > 76.0)
771  {
773  report->getAltFrequencies()->back()->setFrequency(*it);
774  }
775  }
776 }
void setAltFrequencies(QList< SWGRDSReport_altFrequencies *> *alt_frequencies)
void setRadioText(QString *radio_text)
void setProgServiceName(QString *prog_service_name)
static double dbPower(double magsq, double floor=1e-12)
Definition: db.cpp:22
QList< SWGRDSReport_altFrequencies * > * getAltFrequencies()
Real getDemodAcc() const
Definition: bfmdemod.h:159
void setDemodStatus(qint32 demod_status)
void setRdsDemodFrequency(float rds_demod_frequency)
std::set< double > m_g0_alt_freq
Definition: rdsparser.h:67
void setDecodStatus(qint32 decod_status)
void setRdsDemodAccumDb(float rds_demod_accum_db)
Real getDemodQua() const
Definition: bfmdemod.h:160
void setMonoStereo(QString *mono_stereo)
Real getDecoderQua() const
Definition: bfmdemod.h:157
void setPiCoverage(QString *pi_coverage)
Real getDemodFclk() const
Definition: bfmdemod.h:161
void setPiType(QString *pi_type)
void setTime(QString *time)
void setPid(QString *pid)
RDSParser & getRDSParser()
Definition: bfmdemod.h:181
void setMusicSpeech(QString *music_speech)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

int BFMDemod::webapiReportGet ( SWGSDRangel::SWGChannelReport response,
QString &  errorMessage 
)
virtual

Reimplemented from ChannelAPI.

Definition at line 677 of file bfmdemod.cpp.

References SWGSDRangel::SWGChannelReport::getBfmDemodReport(), SWGSDRangel::SWGBFMDemodReport::init(), SWGSDRangel::SWGChannelReport::setBfmDemodReport(), and webapiFormatChannelReport().

680 {
681  (void) errorMessage;
683  response.getBfmDemodReport()->init();
684  webapiFormatChannelReport(response);
685  return 200;
686 }
SWGBFMDemodReport * getBfmDemodReport()
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
Definition: bfmdemod.cpp:726
void setBfmDemodReport(SWGBFMDemodReport *bfm_demod_report)
+ Here is the call graph for this function:

◆ webapiReverseSendSettings()

void BFMDemod::webapiReverseSendSettings ( QList< QString > &  channelSettingsKeys,
const BFMDemodSettings settings,
bool  force 
)
private

Definition at line 778 of file bfmdemod.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), SWGSDRangel::SWGChannelSettings::getBfmDemodSettings(), ChannelAPI::getDeviceSetIndex(), ChannelAPI::getIndexInDeviceSet(), BFMDemodSettings::m_afBandwidth, BFMDemodSettings::m_audioDeviceName, BFMDemodSettings::m_audioStereo, BFMDemodSettings::m_inputFrequencyOffset, BFMDemodSettings::m_lsbStereo, m_networkManager, m_networkRequest, BFMDemodSettings::m_rdsActive, BFMDemodSettings::m_reverseAPIAddress, BFMDemodSettings::m_reverseAPIChannelIndex, BFMDemodSettings::m_reverseAPIDeviceIndex, BFMDemodSettings::m_reverseAPIPort, BFMDemodSettings::m_rfBandwidth, BFMDemodSettings::m_rgbColor, BFMDemodSettings::m_showPilot, BFMDemodSettings::m_squelch, BFMDemodSettings::m_title, BFMDemodSettings::m_volume, SWGSDRangel::SWGBFMDemodSettings::setAfBandwidth(), SWGSDRangel::SWGBFMDemodSettings::setAudioDeviceName(), SWGSDRangel::SWGBFMDemodSettings::setAudioStereo(), SWGSDRangel::SWGChannelSettings::setBfmDemodSettings(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGBFMDemodSettings::setInputFrequencyOffset(), SWGSDRangel::SWGBFMDemodSettings::setLsbStereo(), SWGSDRangel::SWGChannelSettings::setOriginatorChannelIndex(), SWGSDRangel::SWGChannelSettings::setOriginatorDeviceSetIndex(), SWGSDRangel::SWGBFMDemodSettings::setRdsActive(), SWGSDRangel::SWGBFMDemodSettings::setRfBandwidth(), SWGSDRangel::SWGBFMDemodSettings::setRgbColor(), SWGSDRangel::SWGBFMDemodSettings::setShowPilot(), SWGSDRangel::SWGBFMDemodSettings::setSquelch(), SWGSDRangel::SWGBFMDemodSettings::setTitle(), and SWGSDRangel::SWGBFMDemodSettings::setVolume().

Referenced by applySettings().

779 {
781  swgChannelSettings->setDirection(0); // single sink (Rx)
782  swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
783  swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
784  swgChannelSettings->setChannelType(new QString("BFMDemod"));
785  swgChannelSettings->setBfmDemodSettings(new SWGSDRangel::SWGBFMDemodSettings());
786  SWGSDRangel::SWGBFMDemodSettings *swgBFMDemodSettings = swgChannelSettings->getBfmDemodSettings();
787 
788  // transfer data that has been modified. When force is on transfer all data except reverse API data
789 
790  if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
791  swgBFMDemodSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
792  }
793  if (channelSettingsKeys.contains("rfBandwidth") || force) {
794  swgBFMDemodSettings->setRfBandwidth(settings.m_rfBandwidth);
795  }
796  if (channelSettingsKeys.contains("afBandwidth") || force) {
797  swgBFMDemodSettings->setAfBandwidth(settings.m_afBandwidth);
798  }
799  if (channelSettingsKeys.contains("volume") || force) {
800  swgBFMDemodSettings->setVolume(settings.m_volume);
801  }
802  if (channelSettingsKeys.contains("squelch") || force) {
803  swgBFMDemodSettings->setSquelch(settings.m_squelch);
804  }
805  if (channelSettingsKeys.contains("audioStereo") || force) {
806  swgBFMDemodSettings->setAudioStereo(settings.m_audioStereo ? 1 : 0);
807  }
808  if (channelSettingsKeys.contains("lsbStereo") || force) {
809  swgBFMDemodSettings->setLsbStereo(settings.m_lsbStereo ? 1 : 0);
810  }
811  if (channelSettingsKeys.contains("showPilot") || force) {
812  swgBFMDemodSettings->setShowPilot(settings.m_showPilot ? 1 : 0);
813  }
814  if (channelSettingsKeys.contains("rdsActive") || force) {
815  swgBFMDemodSettings->setRdsActive(settings.m_rdsActive ? 1 : 0);
816  }
817  if (channelSettingsKeys.contains("rgbColor") || force) {
818  swgBFMDemodSettings->setRgbColor(settings.m_rgbColor);
819  }
820  if (channelSettingsKeys.contains("title") || force) {
821  swgBFMDemodSettings->setTitle(new QString(settings.m_title));
822  }
823  if (channelSettingsKeys.contains("audioDeviceName") || force) {
824  swgBFMDemodSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
825  }
826 
827  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
828  .arg(settings.m_reverseAPIAddress)
829  .arg(settings.m_reverseAPIPort)
830  .arg(settings.m_reverseAPIDeviceIndex)
831  .arg(settings.m_reverseAPIChannelIndex);
832  m_networkRequest.setUrl(QUrl(channelSettingsURL));
833  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
834 
835  QBuffer *buffer=new QBuffer();
836  buffer->open((QBuffer::ReadWrite));
837  buffer->write(swgChannelSettings->asJson().toUtf8());
838  buffer->seek(0);
839 
840  // Always use PATCH to avoid passing reverse API settings
841  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
842 
843  delete swgChannelSettings;
844 }
void setOriginatorChannelIndex(qint32 originator_channel_index)
QString m_reverseAPIAddress
void setBfmDemodSettings(SWGBFMDemodSettings *bfm_demod_settings)
uint16_t m_reverseAPIChannelIndex
qint64 m_inputFrequencyOffset
int getDeviceSetIndex() const
Definition: channelapi.h:89
void setAudioDeviceName(QString *audio_device_name)
void setChannelType(QString *channel_type)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
uint16_t m_reverseAPIDeviceIndex
SWGBFMDemodSettings * getBfmDemodSettings()
uint16_t m_reverseAPIPort
virtual QString asJson() override
void setInputFrequencyOffset(qint64 input_frequency_offset)
QNetworkAccessManager * m_networkManager
Definition: bfmdemod.h:288
void setAudioStereo(qint32 audio_stereo)
int getIndexInDeviceSet() const
Definition: channelapi.h:87
QNetworkRequest m_networkRequest
Definition: bfmdemod.h:289
void setAfBandwidth(float af_bandwidth)
void setRfBandwidth(float rf_bandwidth)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

int BFMDemod::webapiSettingsGet ( SWGSDRangel::SWGChannelSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from ChannelAPI.

Definition at line 580 of file bfmdemod.cpp.

References SWGSDRangel::SWGChannelSettings::getBfmDemodSettings(), SWGSDRangel::SWGBFMDemodSettings::init(), m_settings, SWGSDRangel::SWGChannelSettings::setBfmDemodSettings(), and webapiFormatChannelSettings().

583 {
584  (void) errorMessage;
586  response.getBfmDemodSettings()->init();
588  return 200;
589 }
void setBfmDemodSettings(SWGBFMDemodSettings *bfm_demod_settings)
SWGBFMDemodSettings * getBfmDemodSettings()
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const BFMDemodSettings &settings)
Definition: bfmdemod.cpp:688
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
+ Here is the call graph for this function:

◆ webapiSettingsPutPatch()

int BFMDemod::webapiSettingsPutPatch ( bool  force,
const QStringList &  channelSettingsKeys,
SWGSDRangel::SWGChannelSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from ChannelAPI.

Definition at line 591 of file bfmdemod.cpp.

References BFMDemod::MsgConfigureBFMDemod::create(), BFMDemod::MsgConfigureChannelizer::create(), SWGSDRangel::SWGBFMDemodSettings::getAfBandwidth(), SWGSDRangel::SWGBFMDemodSettings::getAudioDeviceName(), SWGSDRangel::SWGBFMDemodSettings::getAudioStereo(), SWGSDRangel::SWGChannelSettings::getBfmDemodSettings(), SWGSDRangel::SWGBFMDemodSettings::getInputFrequencyOffset(), SWGSDRangel::SWGBFMDemodSettings::getLsbStereo(), SWGSDRangel::SWGBFMDemodSettings::getRdsActive(), SWGSDRangel::SWGBFMDemodSettings::getReverseApiAddress(), SWGSDRangel::SWGBFMDemodSettings::getReverseApiChannelIndex(), SWGSDRangel::SWGBFMDemodSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGBFMDemodSettings::getReverseApiPort(), SWGSDRangel::SWGBFMDemodSettings::getRfBandwidth(), SWGSDRangel::SWGBFMDemodSettings::getRgbColor(), SWGSDRangel::SWGBFMDemodSettings::getShowPilot(), SWGSDRangel::SWGBFMDemodSettings::getSquelch(), SWGSDRangel::SWGBFMDemodSettings::getTitle(), SWGSDRangel::SWGBFMDemodSettings::getUseReverseApi(), SWGSDRangel::SWGBFMDemodSettings::getVolume(), BFMDemodSettings::m_afBandwidth, BFMDemodSettings::m_audioDeviceName, BFMDemodSettings::m_audioStereo, BasebandSampleSink::m_guiMessageQueue, BFMDemodSettings::m_inputFrequencyOffset, BasebandSampleSink::m_inputMessageQueue, BFMDemodSettings::m_lsbStereo, BFMDemodSettings::m_rdsActive, BFMDemodSettings::m_reverseAPIAddress, BFMDemodSettings::m_reverseAPIChannelIndex, BFMDemodSettings::m_reverseAPIDeviceIndex, BFMDemodSettings::m_reverseAPIPort, BFMDemodSettings::m_rfBandwidth, BFMDemodSettings::m_rgbColor, m_settings, BFMDemodSettings::m_showPilot, BFMDemodSettings::m_squelch, BFMDemodSettings::m_title, BFMDemodSettings::m_useReverseAPI, BFMDemodSettings::m_volume, MessageQueue::push(), requiredBW(), and webapiFormatChannelSettings().

596 {
597  (void) errorMessage;
598  BFMDemodSettings settings = m_settings;
599  bool frequencyOffsetChanged = false;
600 
601  if (channelSettingsKeys.contains("inputFrequencyOffset"))
602  {
604  frequencyOffsetChanged = true;
605  }
606  if (channelSettingsKeys.contains("rfBandwidth")) {
607  settings.m_rfBandwidth = response.getBfmDemodSettings()->getRfBandwidth();
608  }
609  if (channelSettingsKeys.contains("afBandwidth")) {
610  settings.m_afBandwidth = response.getBfmDemodSettings()->getAfBandwidth();
611  }
612  if (channelSettingsKeys.contains("volume")) {
613  settings.m_volume = response.getBfmDemodSettings()->getVolume();
614  }
615  if (channelSettingsKeys.contains("squelch")) {
616  settings.m_squelch = response.getBfmDemodSettings()->getSquelch();
617  }
618  if (channelSettingsKeys.contains("audioStereo")) {
619  settings.m_audioStereo = response.getBfmDemodSettings()->getAudioStereo() != 0;
620  }
621  if (channelSettingsKeys.contains("lsbStereo")) {
622  settings.m_lsbStereo = response.getBfmDemodSettings()->getLsbStereo() != 0;
623  }
624  if (channelSettingsKeys.contains("showPilot")) {
625  settings.m_showPilot = response.getBfmDemodSettings()->getShowPilot() != 0;
626  }
627  if (channelSettingsKeys.contains("rdsActive")) {
628  settings.m_rdsActive = response.getBfmDemodSettings()->getRdsActive() != 0;
629  }
630  if (channelSettingsKeys.contains("rgbColor")) {
631  settings.m_rgbColor = response.getBfmDemodSettings()->getRgbColor();
632  }
633  if (channelSettingsKeys.contains("title")) {
634  settings.m_title = *response.getBfmDemodSettings()->getTitle();
635  }
636  if (channelSettingsKeys.contains("audioDeviceName")) {
637  settings.m_audioDeviceName = *response.getBfmDemodSettings()->getAudioDeviceName();
638  }
639  if (channelSettingsKeys.contains("useReverseAPI")) {
640  settings.m_useReverseAPI = response.getBfmDemodSettings()->getUseReverseApi() != 0;
641  }
642  if (channelSettingsKeys.contains("reverseAPIAddress")) {
644  }
645  if (channelSettingsKeys.contains("reverseAPIPort")) {
646  settings.m_reverseAPIPort = response.getBfmDemodSettings()->getReverseApiPort();
647  }
648  if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
650  }
651  if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
653  }
654 
655  if (frequencyOffsetChanged)
656  {
657  MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
658  requiredBW(settings.m_rfBandwidth), settings.m_inputFrequencyOffset);
659  m_inputMessageQueue.push(channelConfigMsg);
660  }
661 
662  MsgConfigureBFMDemod *msg = MsgConfigureBFMDemod::create(settings, force);
664 
665  qDebug("BFMDemod::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
666  if (m_guiMessageQueue) // forward to GUI if any
667  {
668  MsgConfigureBFMDemod *msgToGUI = MsgConfigureBFMDemod::create(settings, force);
669  m_guiMessageQueue->push(msgToGUI);
670  }
671 
672  webapiFormatChannelSettings(response, settings);
673 
674  return 200;
675 }
QString m_reverseAPIAddress
void push(Message *message, bool emitSignal=true)
Push message onto queue.
uint16_t m_reverseAPIChannelIndex
qint64 m_inputFrequencyOffset
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: bfmdemod.h:88
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
uint16_t m_reverseAPIDeviceIndex
static int requiredBW(int rfBW)
Definition: bfmdemod.h:197
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
SWGBFMDemodSettings * getBfmDemodSettings()
uint16_t m_reverseAPIPort
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const BFMDemodSettings &settings)
Definition: bfmdemod.cpp:688
BFMDemodSettings m_settings
Definition: bfmdemod.h:231
static MsgConfigureBFMDemod * create(const BFMDemodSettings &settings, bool force)
Definition: bfmdemod.h:65
+ Here is the call graph for this function:

Member Data Documentation

◆ default_deemphasis

const Real BFMDemod::default_deemphasis = 50.0
staticprivate

Definition at line 279 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), and BFMDemod().

◆ default_excursion

const int BFMDemod::default_excursion = 750000
staticprivate

Definition at line 282 of file bfmdemod.h.

◆ filtFftLen

const int BFMDemod::filtFftLen = 1024
staticprivate

Definition at line 249 of file bfmdemod.h.

Referenced by BFMDemod().

◆ m_audioBuffer

AudioVector BFMDemod::m_audioBuffer
private

Definition at line 262 of file bfmdemod.h.

Referenced by BFMDemod(), and feed().

◆ m_audioBufferFill

uint BFMDemod::m_audioBufferFill
private

Definition at line 263 of file bfmdemod.h.

Referenced by BFMDemod(), and feed().

◆ m_audioFifo

AudioFifo BFMDemod::m_audioFifo
private

Definition at line 266 of file bfmdemod.h.

Referenced by applySettings(), BFMDemod(), feed(), start(), and ~BFMDemod().

◆ m_audioSampleRate

quint32 BFMDemod::m_audioSampleRate
private

◆ m_channelId

const QString BFMDemod::m_channelId = "BFMDemod"
static

Definition at line 207 of file bfmdemod.h.

Referenced by BFMDemod(), and BFMPlugin::initPlugin().

◆ m_channelIdURI

const QString BFMDemod::m_channelIdURI = "sdrangel.channel.bfm"
static

Definition at line 206 of file bfmdemod.h.

Referenced by BFMDemodGUI::BFMDemodGUI(), and BFMPlugin::initPlugin().

◆ m_channelizer

DownChannelizer* BFMDemod::m_channelizer
private

Definition at line 227 of file bfmdemod.h.

Referenced by BFMDemod(), handleMessage(), and ~BFMDemod().

◆ m_deemphasisFilterX

LowPassFilterRC BFMDemod::m_deemphasisFilterX
private

Definition at line 277 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), BFMDemod(), and feed().

◆ m_deemphasisFilterY

LowPassFilterRC BFMDemod::m_deemphasisFilterY
private

Definition at line 278 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), BFMDemod(), and feed().

◆ m_deviceAPI

DeviceAPI* BFMDemod::m_deviceAPI
private

Definition at line 225 of file bfmdemod.h.

Referenced by BFMDemod(), and ~BFMDemod().

◆ m_fmExcursion

Real BFMDemod::m_fmExcursion
private

Definition at line 281 of file bfmdemod.h.

Referenced by applyChannelSettings(), applySettings(), and BFMDemod().

◆ m_inputFrequencyOffset

int BFMDemod::m_inputFrequencyOffset
private

Definition at line 230 of file bfmdemod.h.

Referenced by applyChannelSettings(), BFMDemod(), and start().

◆ m_inputSampleRate

int BFMDemod::m_inputSampleRate
private

◆ m_interpolator

Interpolator BFMDemod::m_interpolator
private

Interpolator between fixed demod bandwidth and audio bandwidth (rational)

Definition at line 235 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), applyChannelSettings(), applySettings(), and feed().

◆ m_interpolatorDistance

Real BFMDemod::m_interpolatorDistance
private

Definition at line 236 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), applyChannelSettings(), applySettings(), BFMDemod(), and feed().

◆ m_interpolatorDistanceRemain

Real BFMDemod::m_interpolatorDistanceRemain
private

Definition at line 237 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), applyChannelSettings(), applySettings(), BFMDemod(), and feed().

◆ m_interpolatorRDS

Interpolator BFMDemod::m_interpolatorRDS
private

Twin Interpolator for stereo subcarrier.

Definition at line 243 of file bfmdemod.h.

Referenced by applyChannelSettings(), applySettings(), and feed().

◆ m_interpolatorRDSDistance

Real BFMDemod::m_interpolatorRDSDistance
private

Definition at line 244 of file bfmdemod.h.

Referenced by applyChannelSettings(), applySettings(), BFMDemod(), and feed().

◆ m_interpolatorRDSDistanceRemain

Real BFMDemod::m_interpolatorRDSDistanceRemain
private

Definition at line 245 of file bfmdemod.h.

Referenced by applyChannelSettings(), applySettings(), BFMDemod(), and feed().

◆ m_interpolatorStereo

Interpolator BFMDemod::m_interpolatorStereo
private

Twin Interpolator for stereo subcarrier.

Definition at line 239 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), applyChannelSettings(), applySettings(), and feed().

◆ m_interpolatorStereoDistance

Real BFMDemod::m_interpolatorStereoDistance
private

Definition at line 240 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), applyChannelSettings(), applySettings(), BFMDemod(), and feed().

◆ m_interpolatorStereoDistanceRemain

Real BFMDemod::m_interpolatorStereoDistanceRemain
private

Definition at line 241 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), applyChannelSettings(), applySettings(), BFMDemod(), and feed().

◆ m_lowpass

Lowpass<Real> BFMDemod::m_lowpass
private

Definition at line 247 of file bfmdemod.h.

Referenced by applySettings().

◆ m_m1Arg

Real BFMDemod::m_m1Arg
private

Definition at line 254 of file bfmdemod.h.

Referenced by BFMDemod().

◆ m_magsq

double BFMDemod::m_magsq
private

x^-1 real sample

Definition at line 256 of file bfmdemod.h.

Referenced by BFMDemod().

◆ m_magsqCount

int BFMDemod::m_magsqCount
private

Definition at line 259 of file bfmdemod.h.

Referenced by BFMDemod(), and feed().

◆ m_magSqLevelStore

MagSqLevelsStore BFMDemod::m_magSqLevelStore
private

Definition at line 260 of file bfmdemod.h.

◆ m_magsqPeak

double BFMDemod::m_magsqPeak
private

Definition at line 258 of file bfmdemod.h.

Referenced by BFMDemod(), and feed().

◆ m_magsqSum

double BFMDemod::m_magsqSum
private

Definition at line 257 of file bfmdemod.h.

Referenced by BFMDemod(), and feed().

◆ m_nco

NCO BFMDemod::m_nco
private

Definition at line 234 of file bfmdemod.h.

Referenced by applyChannelSettings(), and feed().

◆ m_networkManager

QNetworkAccessManager* BFMDemod::m_networkManager
private

Definition at line 288 of file bfmdemod.h.

Referenced by BFMDemod(), webapiReverseSendSettings(), and ~BFMDemod().

◆ m_networkRequest

QNetworkRequest BFMDemod::m_networkRequest
private

Definition at line 289 of file bfmdemod.h.

Referenced by webapiReverseSendSettings().

◆ m_phaseDiscri

PhaseDiscriminators BFMDemod::m_phaseDiscri
private

Definition at line 284 of file bfmdemod.h.

Referenced by applyChannelSettings(), applySettings(), BFMDemod(), feed(), and start().

◆ m_pilotPLL

RDSPhaseLock BFMDemod::m_pilotPLL
private

Definition at line 270 of file bfmdemod.h.

Referenced by applyChannelSettings(), applySettings(), and feed().

◆ m_pilotPLLSamples

Real BFMDemod::m_pilotPLLSamples[4]
private

Definition at line 271 of file bfmdemod.h.

Referenced by feed().

◆ m_rdsDecoder

RDSDecoder BFMDemod::m_rdsDecoder
private

Definition at line 274 of file bfmdemod.h.

Referenced by feed().

◆ m_rdsDemod

RDSDemod BFMDemod::m_rdsDemod
private

Definition at line 273 of file bfmdemod.h.

Referenced by feed().

◆ m_rdsParser

RDSParser BFMDemod::m_rdsParser
private

Definition at line 275 of file bfmdemod.h.

Referenced by feed().

◆ m_rfFilter

fftfilt* BFMDemod::m_rfFilter
private

Definition at line 248 of file bfmdemod.h.

Referenced by applyChannelSettings(), applySettings(), BFMDemod(), feed(), and ~BFMDemod().

◆ m_sampleBuffer

SampleVector BFMDemod::m_sampleBuffer
private

Definition at line 267 of file bfmdemod.h.

Referenced by feed().

◆ m_sampleSink

BasebandSampleSink* BFMDemod::m_sampleSink
private

Definition at line 265 of file bfmdemod.h.

Referenced by BFMDemod(), feed(), and handleMessage().

◆ m_settings

BFMDemodSettings BFMDemod::m_settings
private

◆ m_settingsMutex

QMutex BFMDemod::m_settingsMutex
private

Definition at line 268 of file bfmdemod.h.

Referenced by applyAudioSampleRate(), applyChannelSettings(), applySettings(), and feed().

◆ m_squelchLevel

Real BFMDemod::m_squelchLevel
private

Definition at line 251 of file bfmdemod.h.

Referenced by applySettings(), BFMDemod(), and feed().

◆ m_squelchState

int BFMDemod::m_squelchState
private

Definition at line 252 of file bfmdemod.h.

Referenced by BFMDemod(), feed(), start(), and webapiFormatChannelReport().

◆ m_threadedChannelizer

ThreadedBasebandSampleSink* BFMDemod::m_threadedChannelizer
private

Definition at line 226 of file bfmdemod.h.

Referenced by BFMDemod(), and ~BFMDemod().

◆ m_udpBlockSize

const int BFMDemod::m_udpBlockSize = 512
staticprivate

Definition at line 286 of file bfmdemod.h.


The documentation for this class was generated from the following files: