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
WFMDemod Class Reference

#include <wfmdemod.h>

+ Inheritance diagram for WFMDemod:
+ Collaboration diagram for WFMDemod:

Classes

struct  MagSqLevelsStore
 
class  MsgConfigureChannelizer
 
class  MsgConfigureWFMDemod
 

Public Member Functions

 WFMDemod (DeviceAPI *deviceAPI)
 
virtual ~WFMDemod ()
 
virtual void destroy ()
 
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 getSquelchOpen () const
 
void getMagSqLevels (double &avg, double &peak, int &nbSamples)
 
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.wfmdemod"
 
static const QString m_channelId = "WFMDemod"
 

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 WFMDemodSettings &settings, bool force=false)
 
void webapiFormatChannelSettings (SWGSDRangel::SWGChannelSettings &response, const WFMDemodSettings &settings)
 
void webapiFormatChannelReport (SWGSDRangel::SWGChannelReport &response)
 
void webapiReverseSendSettings (QList< QString > &channelSettingsKeys, const WFMDemodSettings &settings, bool force)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSinkm_threadedChannelizer
 
DownChannelizerm_channelizer
 
int m_inputSampleRate
 
int m_inputFrequencyOffset
 
WFMDemodSettings m_settings
 
quint32 m_audioSampleRate
 
NCO m_nco
 
Interpolator m_interpolator
 Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational) More...
 
Real m_interpolatorDistance
 
Real m_interpolatorDistanceRemain
 
fftfiltm_rfFilter
 
Real m_squelchLevel
 
int m_squelchState
 
bool m_squelchOpen
 
double m_magsq
 displayed averaged value More...
 
double m_magsqSum
 
double m_magsqPeak
 
int m_magsqCount
 
MagSqLevelsStore m_magSqLevelStore
 
MovingAverageUtil< Real, double, 16 > m_movingAverage
 
Real m_fmExcursion
 
AudioVector m_audioBuffer
 
uint m_audioBufferFill
 
AudioFifo m_audioFifo
 
SampleVector m_sampleBuffer
 
QMutex m_settingsMutex
 
PhaseDiscriminators m_phaseDiscri
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 

Static Private Attributes

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 48 of file wfmdemod.h.

Member Enumeration Documentation

◆ RateState

enum WFMDemod::RateState
private
Enumerator
RSInitialFill 
RSRunning 

Definition at line 181 of file wfmdemod.h.

Constructor & Destructor Documentation

◆ WFMDemod()

WFMDemod::WFMDemod ( DeviceAPI deviceAPI)

Definition at line 51 of file wfmdemod.cpp.

References AudioDeviceManager::addAudioSink(), DeviceAPI::addChannelSink(), DeviceAPI::addChannelSinkAPI(), applyChannelSettings(), applySettings(), DSPEngine::getAudioDeviceManager(), BasebandSampleSink::getInputMessageQueue(), AudioDeviceManager::getOutputSampleRate(), DSPEngine::instance(), m_audioBuffer, m_audioBufferFill, m_audioFifo, m_audioSampleRate, m_channelId, m_channelizer, m_deviceAPI, m_inputFrequencyOffset, m_inputSampleRate, m_networkManager, m_phaseDiscri, m_rfFilter, m_settings, m_threadedChannelizer, networkManagerFinished(), rfFilterFftLength, and PhaseDiscriminators::setFMScaling().

Referenced by WFMDemod::MsgConfigureChannelizer::MsgConfigureChannelizer().

51  :
53  m_deviceAPI(deviceAPI),
54  m_inputSampleRate(384000),
56  m_squelchOpen(false),
57  m_magsq(0.0f),
58  m_magsqSum(0.0f),
59  m_magsqPeak(0.0f),
60  m_magsqCount(0),
61  m_audioFifo(250000),
62  m_settingsMutex(QMutex::Recursive)
63 {
64  setObjectName(m_channelId);
65 
66  m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, rfFilterFftLength);
67  m_phaseDiscri.setFMScaling(384000/75000);
68 
69  m_audioBuffer.resize(16384);
71 
74 
77 
78  m_channelizer = new DownChannelizer(this);
82 
83  m_networkManager = new QNetworkAccessManager();
84  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
85 }
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
void networkManagerFinished(QNetworkReply *reply)
Definition: wfmdemod.cpp:645
int getOutputSampleRate(int outputDeviceIndex=-1)
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: wfmdemod.h:187
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void setFMScaling(Real fmScaling)
Definition: phasediscri.h:42
int m_inputSampleRate
Definition: wfmdemod.h:190
DeviceAPI * m_deviceAPI
Definition: wfmdemod.h:186
bool m_squelchOpen
Definition: wfmdemod.h:203
AudioVector m_audioBuffer
Definition: wfmdemod.h:213
double m_magsqPeak
Definition: wfmdemod.h:206
static DSPEngine * instance()
Definition: dspengine.cpp:51
fftfilt * m_rfFilter
Definition: wfmdemod.h:199
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
quint32 m_audioSampleRate
Definition: wfmdemod.h:193
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: wfmdemod.cpp:288
QNetworkAccessManager * m_networkManager
Definition: wfmdemod.h:222
double m_magsq
displayed averaged value
Definition: wfmdemod.h:204
static const QString m_channelIdURI
Definition: wfmdemod.h:167
void applySettings(const WFMDemodSettings &settings, bool force=false)
Definition: wfmdemod.cpp:321
Exposes a single sink stream (input, Rx)
Definition: channelapi.h:41
static const QString m_channelId
Definition: wfmdemod.h:168
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
uint m_audioBufferFill
Definition: wfmdemod.h:214
QMutex m_settingsMutex
Definition: wfmdemod.h:218
int m_inputFrequencyOffset
Definition: wfmdemod.h:191
int m_magsqCount
Definition: wfmdemod.h:207
DownChannelizer * m_channelizer
Definition: wfmdemod.h:188
double m_magsqSum
Definition: wfmdemod.h:205
AudioFifo m_audioFifo
Definition: wfmdemod.h:216
#define rfFilterFftLength
Definition: datvdemod.h:27
PhaseDiscriminators m_phaseDiscri
Definition: wfmdemod.h:220
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~WFMDemod()

WFMDemod::~WFMDemod ( )
virtual

Definition at line 87 of file wfmdemod.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().

Referenced by WFMDemod::MsgConfigureChannelizer::MsgConfigureChannelizer().

88 {
89  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
90  delete m_networkManager;
92 
95  delete m_threadedChannelizer;
96  delete m_channelizer;
97  delete m_rfFilter;
98 }
void networkManagerFinished(QNetworkReply *reply)
Definition: wfmdemod.cpp:645
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: wfmdemod.h:187
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
void removeAudioSink(AudioFifo *audioFifo)
Remove the audio sink.
DeviceAPI * m_deviceAPI
Definition: wfmdemod.h:186
static DSPEngine * instance()
Definition: dspengine.cpp:51
fftfilt * m_rfFilter
Definition: wfmdemod.h:199
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
QNetworkAccessManager * m_networkManager
Definition: wfmdemod.h:222
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
DownChannelizer * m_channelizer
Definition: wfmdemod.h:188
AudioFifo m_audioFifo
Definition: wfmdemod.h:216
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applyAudioSampleRate()

void WFMDemod::applyAudioSampleRate ( int  sampleRate)
private

Definition at line 273 of file wfmdemod.cpp.

References Interpolator::create(), WFMDemodSettings::m_afBandwidth, m_audioSampleRate, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_settings, and m_settingsMutex.

Referenced by applySettings(), and handleMessage().

274 {
275  qDebug("WFMDemod::applyAudioSampleRate: %d", sampleRate);
276 
277  m_settingsMutex.lock();
278 
282 
283  m_settingsMutex.unlock();
284 
285  m_audioSampleRate = sampleRate;
286 }
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
int m_inputSampleRate
Definition: wfmdemod.h:190
Real m_interpolatorDistance
Definition: wfmdemod.h:197
Interpolator m_interpolator
Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational) ...
Definition: wfmdemod.h:196
quint32 m_audioSampleRate
Definition: wfmdemod.h:193
QMutex m_settingsMutex
Definition: wfmdemod.h:218
Real m_interpolatorDistanceRemain
Definition: wfmdemod.h:198
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyChannelSettings()

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

Definition at line 288 of file wfmdemod.cpp.

References Interpolator::create(), fftfilt::create_filter(), WFMDemodSettings::m_afBandwidth, m_audioSampleRate, m_fmExcursion, m_inputFrequencyOffset, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_nco, m_phaseDiscri, WFMDemodSettings::m_rfBandwidth, m_rfFilter, m_settings, m_settingsMutex, PhaseDiscriminators::setFMScaling(), and NCO::setFreq().

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

289 {
290  qDebug() << "WFMDemod::applyChannelSettings:"
291  << " inputSampleRate: " << inputSampleRate
292  << " inputFrequencyOffset: " << inputFrequencyOffset;
293 
294  if((inputFrequencyOffset != m_inputFrequencyOffset) ||
295  (inputSampleRate != m_inputSampleRate) || force)
296  {
297  m_nco.setFreq(-inputFrequencyOffset, inputSampleRate);
298  }
299 
300  if ((inputSampleRate != m_inputSampleRate) || force)
301  {
302  qDebug() << "WFMDemod::applyChannelSettings: m_interpolator.create";
303  m_settingsMutex.lock();
304  m_interpolator.create(16, inputSampleRate, m_settings.m_afBandwidth);
306  m_interpolatorDistance = (Real) inputSampleRate / (Real) m_audioSampleRate;
307  m_settingsMutex.unlock();
308  qDebug() << "WFMDemod::applySettings: m_rfFilter->create_filter";
309  Real lowCut = -(m_settings.m_rfBandwidth / 2.0) / inputSampleRate;
310  Real hiCut = (m_settings.m_rfBandwidth / 2.0) / inputSampleRate;
311  m_rfFilter->create_filter(lowCut, hiCut);
312  m_fmExcursion = m_settings.m_rfBandwidth / (Real) inputSampleRate;
314  qDebug("WFMDemod::applySettings: m_fmExcursion: %f", m_fmExcursion);
315  }
316 
317  m_inputSampleRate = inputSampleRate;
318  m_inputFrequencyOffset = inputFrequencyOffset;
319 }
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
void setFMScaling(Real fmScaling)
Definition: phasediscri.h:42
int m_inputSampleRate
Definition: wfmdemod.h:190
Real m_fmExcursion
Definition: wfmdemod.h:211
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
fftfilt * m_rfFilter
Definition: wfmdemod.h:199
Real m_interpolatorDistance
Definition: wfmdemod.h:197
void setFreq(Real freq, Real sampleRate)
Definition: nco.cpp:49
Interpolator m_interpolator
Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational) ...
Definition: wfmdemod.h:196
quint32 m_audioSampleRate
Definition: wfmdemod.h:193
QMutex m_settingsMutex
Definition: wfmdemod.h:218
NCO m_nco
Definition: wfmdemod.h:195
int m_inputFrequencyOffset
Definition: wfmdemod.h:191
Real m_interpolatorDistanceRemain
Definition: wfmdemod.h:198
float Real
Definition: dsptypes.h:42
PhaseDiscriminators m_phaseDiscri
Definition: wfmdemod.h:220
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySettings()

void WFMDemod::applySettings ( const WFMDemodSettings settings,
bool  force = false 
)
private

Definition at line 321 of file wfmdemod.cpp.

References AudioDeviceManager::addAudioSink(), applyAudioSampleRate(), Interpolator::create(), fftfilt::create_filter(), DSPEngine::getAudioDeviceManager(), BasebandSampleSink::getInputMessageQueue(), AudioDeviceManager::getOutputDeviceIndex(), AudioDeviceManager::getOutputSampleRate(), DSPEngine::instance(), WFMDemodSettings::m_afBandwidth, WFMDemodSettings::m_audioDeviceName, m_audioFifo, WFMDemodSettings::m_audioMute, m_audioSampleRate, m_fmExcursion, WFMDemodSettings::m_inputFrequencyOffset, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_phaseDiscri, WFMDemodSettings::m_reverseAPIAddress, WFMDemodSettings::m_reverseAPIChannelIndex, WFMDemodSettings::m_reverseAPIDeviceIndex, WFMDemodSettings::m_reverseAPIPort, WFMDemodSettings::m_rfBandwidth, m_rfFilter, WFMDemodSettings::m_rgbColor, m_settings, m_settingsMutex, WFMDemodSettings::m_squelch, m_squelchLevel, WFMDemodSettings::m_title, WFMDemodSettings::m_useReverseAPI, WFMDemodSettings::m_volume, PhaseDiscriminators::setFMScaling(), and webapiReverseSendSettings().

Referenced by handleMessage(), and WFMDemod().

322 {
323  qDebug() << "WFMDemod::applySettings:"
324  << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
325  << " m_rfBandwidth: " << settings.m_rfBandwidth
326  << " m_afBandwidth: " << settings.m_afBandwidth
327  << " m_volume: " << settings.m_volume
328  << " m_squelch: " << settings.m_squelch
329  << " m_audioDeviceName: " << settings.m_audioDeviceName
330  << " m_audioMute: " << settings.m_audioMute
331  << " m_useReverseAPI: " << settings.m_useReverseAPI
332  << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
333  << " m_reverseAPIPort: " << settings.m_reverseAPIPort
334  << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
335  << " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
336  << " force: " << force;
337 
338  QList<QString> reverseAPIKeys;
339 
340  if((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
341  reverseAPIKeys.append("inputFrequencyOffset");
342  }
343  if((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
344  reverseAPIKeys.append("rfBandwidth");
345  }
346  if((settings.m_afBandwidth != m_settings.m_afBandwidth) || force) {
347  reverseAPIKeys.append("afBandwidth");
348  }
349  if((settings.m_volume != m_settings.m_volume) || force) {
350  reverseAPIKeys.append("volume");
351  }
352  if((settings.m_squelch != m_settings.m_squelch) || force) {
353  reverseAPIKeys.append("squelch");
354  }
355  if((settings.m_audioMute != m_settings.m_audioMute) || force) {
356  reverseAPIKeys.append("audioMute");
357  }
358  if((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) {
359  reverseAPIKeys.append("audioDeviceName");
360  }
361  if((settings.m_title != m_settings.m_title) || force) {
362  reverseAPIKeys.append("title");
363  }
364  if((settings.m_rgbColor != m_settings.m_rgbColor) || force) {
365  reverseAPIKeys.append("rgbColor");
366  }
367 
368  if((settings.m_afBandwidth != m_settings.m_afBandwidth) ||
369  (settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force)
370  {
371  m_settingsMutex.lock();
372  qDebug() << "WFMDemod::applySettings: m_interpolator.create";
376  qDebug() << "WFMDemod::applySettings: m_rfFilter->create_filter";
377  Real lowCut = -(settings.m_rfBandwidth / 2.0) / m_inputSampleRate;
378  Real hiCut = (settings.m_rfBandwidth / 2.0) / m_inputSampleRate;
379  m_rfFilter->create_filter(lowCut, hiCut);
382  qDebug("WFMDemod::applySettings: m_fmExcursion: %f", m_fmExcursion);
383  m_settingsMutex.unlock();
384  }
385 
386  if ((settings.m_squelch != m_settings.m_squelch) || force)
387  {
388  qDebug() << "WFMDemod::applySettings: set m_squelchLevel";
389  m_squelchLevel = pow(10.0, settings.m_squelch / 10.0);
390  }
391 
392  if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
393  {
395  int audioDeviceIndex = audioDeviceManager->getOutputDeviceIndex(settings.m_audioDeviceName);
396  //qDebug("AMDemod::applySettings: audioDeviceName: %s audioDeviceIndex: %d", qPrintable(settings.m_audioDeviceName), audioDeviceIndex);
397  audioDeviceManager->addAudioSink(&m_audioFifo, getInputMessageQueue(), audioDeviceIndex);
398  uint32_t audioSampleRate = audioDeviceManager->getOutputSampleRate(audioDeviceIndex);
399 
400  if (m_audioSampleRate != audioSampleRate) {
401  applyAudioSampleRate(audioSampleRate);
402  }
403  }
404 
405  if (settings.m_useReverseAPI)
406  {
407  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
412  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
413  }
414 
415  m_settings = settings;
416 }
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
qint64 m_inputFrequencyOffset
int getOutputSampleRate(int outputDeviceIndex=-1)
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void setFMScaling(Real fmScaling)
Definition: phasediscri.h:42
uint16_t m_reverseAPIPort
int getOutputDeviceIndex(const QString &deviceName) const
uint16_t m_reverseAPIChannelIndex
int m_inputSampleRate
Definition: wfmdemod.h:190
Real m_fmExcursion
Definition: wfmdemod.h:211
unsigned int uint32_t
Definition: rtptypes_win.h:46
Real m_squelchLevel
Definition: wfmdemod.h:201
uint16_t m_reverseAPIDeviceIndex
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
static DSPEngine * instance()
Definition: dspengine.cpp:51
fftfilt * m_rfFilter
Definition: wfmdemod.h:199
QString m_reverseAPIAddress
Real m_interpolatorDistance
Definition: wfmdemod.h:197
Interpolator m_interpolator
Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational) ...
Definition: wfmdemod.h:196
quint32 m_audioSampleRate
Definition: wfmdemod.h:193
void applyAudioSampleRate(int sampleRate)
Definition: wfmdemod.cpp:273
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const WFMDemodSettings &settings, bool force)
Definition: wfmdemod.cpp:586
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
QMutex m_settingsMutex
Definition: wfmdemod.h:218
Real m_interpolatorDistanceRemain
Definition: wfmdemod.h:198
AudioFifo m_audioFifo
Definition: wfmdemod.h:216
float Real
Definition: dsptypes.h:42
PhaseDiscriminators m_phaseDiscri
Definition: wfmdemod.h:220
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements ChannelAPI.

Definition at line 423 of file wfmdemod.cpp.

References WFMDemod::MsgConfigureWFMDemod::create(), WFMDemodSettings::deserialize(), BasebandSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and WFMDemodSettings::resetToDefaults().

Referenced by getCenterFrequency().

424 {
425  if (m_settings.deserialize(data))
426  {
427  MsgConfigureWFMDemod *msg = MsgConfigureWFMDemod::create(m_settings, true);
429  return true;
430  }
431  else
432  {
434  MsgConfigureWFMDemod *msg = MsgConfigureWFMDemod::create(m_settings, true);
436  return false;
437  }
438 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
bool deserialize(const QByteArray &data)
static MsgConfigureWFMDemod * create(const WFMDemodSettings &settings, bool force)
Definition: wfmdemod.h:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

virtual void WFMDemod::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 99 of file wfmdemod.h.

References feed(), handleMessage(), start(), and stop().

99 { delete this; }
+ Here is the call graph for this function:

◆ feed()

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

Implements BasebandSampleSink.

Definition at line 100 of file wfmdemod.cpp.

References Interpolator::decimate(), i, m_audioBuffer, m_audioBufferFill, m_audioFifo, WFMDemodSettings::m_audioMute, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_magsqCount, m_magsqPeak, m_magsqSum, m_movingAverage, m_nco, m_phaseDiscri, WFMDemodSettings::m_rfBandwidth, m_rfFilter, m_sampleBuffer, m_settings, m_settingsMutex, m_squelchLevel, m_squelchOpen, m_squelchState, WFMDemodSettings::m_volume, NCO::nextIQ(), PhaseDiscriminators::phaseDiscriminatorDelta(), fftfilt::runFilt(), SDR_RX_SCALED, and AudioFifo::write().

Referenced by destroy().

101 {
102  (void) firstOfBurst;
103  Complex ci;
104  fftfilt::cmplx *rf;
105  int rf_out;
106  Real demod;
107  double msq;
108  float fmDev;
109 
110  m_settingsMutex.lock();
111 
112  for (SampleVector::const_iterator it = begin; it != end; ++it)
113  {
114  Complex c(it->real(), it->imag());
115  c *= m_nco.nextIQ();
116 
117  rf_out = m_rfFilter->runFilt(c, &rf); // filter RF before demod
118 
119  for (int i = 0 ; i < rf_out; i++)
120  {
121  msq = rf[i].real()*rf[i].real() + rf[i].imag()*rf[i].imag();
122  Real magsq = msq / (SDR_RX_SCALED*SDR_RX_SCALED);
123  m_magsqSum += magsq;
124  m_movingAverage(magsq);
125 
126  if (magsq > m_magsqPeak) {
127  m_magsqPeak = magsq;
128  }
129 
130  m_magsqCount++;
131 
132  if (magsq >= m_squelchLevel)
133  {
134  if (m_squelchState < m_settings.m_rfBandwidth / 10) { // twice attack and decay rate
135  m_squelchState++;
136  }
137  }
138  else
139  {
140  if (m_squelchState > 0) {
141  m_squelchState--;
142  }
143  }
144 
146 
147  if (m_squelchOpen && !m_settings.m_audioMute) { // squelch open and not mute
148  demod = m_phaseDiscri.phaseDiscriminatorDelta(rf[i], msq, fmDev);
149  } else {
150  demod = 0;
151  }
152 
153  Complex e(demod, 0);
154 
156  {
157  qint16 sample = (qint16)(ci.real() * 3276.8f * m_settings.m_volume);
158  m_sampleBuffer.push_back(Sample(sample, sample));
159  m_audioBuffer[m_audioBufferFill].l = sample;
160  m_audioBuffer[m_audioBufferFill].r = sample;
161 
163 
164  if(m_audioBufferFill >= m_audioBuffer.size())
165  {
166  uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
167 
168  if (res != m_audioBufferFill) {
169  qDebug("WFMDemod::feed: %u/%u audio samples written", res, m_audioBufferFill);
170  }
171 
172  m_audioBufferFill = 0;
173  }
174 
176  }
177  }
178  }
179 
180  if (m_audioBufferFill > 0)
181  {
182  uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
183 
184  if (res != m_audioBufferFill) {
185  qDebug("WFMDemod::feed: %u/%u tail samples written", res, m_audioBufferFill);
186  }
187 
188  m_audioBufferFill = 0;
189  }
190 
191  m_sampleBuffer.clear();
192 
193  m_settingsMutex.unlock();
194 }
Complex nextIQ()
Return next complex sample.
Definition: nco.cpp:61
bool decimate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:38
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
int runFilt(const cmplx &in, cmplx **out)
Definition: fftfilt.cpp:260
bool m_squelchOpen
Definition: wfmdemod.h:203
int m_squelchState
Definition: wfmdemod.h:202
std::complex< float > cmplx
Definition: fftfilt.h:21
Real m_squelchLevel
Definition: wfmdemod.h:201
AudioVector m_audioBuffer
Definition: wfmdemod.h:213
double m_magsqPeak
Definition: wfmdemod.h:206
fftfilt * m_rfFilter
Definition: wfmdemod.h:199
int32_t i
Definition: decimators.h:244
Real m_interpolatorDistance
Definition: wfmdemod.h:197
Interpolator m_interpolator
Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational) ...
Definition: wfmdemod.h:196
MovingAverageUtil< Real, double, 16 > m_movingAverage
Definition: wfmdemod.h:210
uint m_audioBufferFill
Definition: wfmdemod.h:214
QMutex m_settingsMutex
Definition: wfmdemod.h:218
NCO m_nco
Definition: wfmdemod.h:195
SampleVector m_sampleBuffer
Definition: wfmdemod.h:217
Real m_interpolatorDistanceRemain
Definition: wfmdemod.h:198
int m_magsqCount
Definition: wfmdemod.h:207
double m_magsqSum
Definition: wfmdemod.h:205
AudioFifo m_audioFifo
Definition: wfmdemod.h:216
std::complex< Real > Complex
Definition: dsptypes.h:43
Real phaseDiscriminatorDelta(const Complex &sample, double &magsq, Real &fmDev)
Definition: phasediscri.h:62
#define SDR_RX_SCALED
Definition: dsptypes.h:34
float Real
Definition: dsptypes.h:42
PhaseDiscriminators m_phaseDiscri
Definition: wfmdemod.h:220
uint32_t write(const quint8 *data, uint32_t numSamples)
Definition: audiofifo.cpp:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCenterFrequency()

virtual qint64 WFMDemod::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 108 of file wfmdemod.h.

References deserialize(), WFMDemodSettings::m_inputFrequencyOffset, WFMDemod::MsgConfigureWFMDemod::m_settings, and serialize().

qint64 m_inputFrequencyOffset
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
+ Here is the call graph for this function:

◆ getIdentifier()

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

Implements ChannelAPI.

Definition at line 106 of file wfmdemod.h.

106 { id = objectName(); }

◆ getMagSq()

double WFMDemod::getMagSq ( ) const
inline

Definition at line 123 of file wfmdemod.h.

References MovingAverageUtil< T, Total, N >::asDouble(), and m_movingAverage.

123 { return m_movingAverage.asDouble(); }
MovingAverageUtil< Real, double, 16 > m_movingAverage
Definition: wfmdemod.h:210
double asDouble() const
Definition: movingaverage.h:57
+ Here is the call graph for this function:

◆ getMagSqLevels()

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

Definition at line 126 of file wfmdemod.h.

References WFMDemod::MagSqLevelsStore::m_magsq, m_magsq, m_magsqCount, m_magSqLevelStore, WFMDemod::MagSqLevelsStore::m_magsqPeak, m_magsqPeak, m_magsqSum, webapiReportGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

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

127  {
128  if (m_magsqCount > 0)
129  {
133  }
134 
137  nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
138 
139  m_magsqSum = 0.0f;
140  m_magsqPeak = 0.0f;
141  m_magsqCount = 0;
142  }
double m_magsqPeak
Definition: wfmdemod.h:206
double m_magsq
displayed averaged value
Definition: wfmdemod.h:204
MagSqLevelsStore m_magSqLevelStore
Definition: wfmdemod.h:208
int m_magsqCount
Definition: wfmdemod.h:207
double m_magsqSum
Definition: wfmdemod.h:205
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNbSinkStreams()

virtual int WFMDemod::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 113 of file wfmdemod.h.

113 { return 1; }

◆ getNbSourceStreams()

virtual int WFMDemod::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 114 of file wfmdemod.h.

114 { return 0; }

◆ getSquelchOpen()

bool WFMDemod::getSquelchOpen ( ) const
inline

Definition at line 124 of file wfmdemod.h.

References m_squelchOpen.

Referenced by WFMDemodGUI::tick().

124 { return m_squelchOpen; }
bool m_squelchOpen
Definition: wfmdemod.h:203
+ Here is the caller graph for this function:

◆ getStreamCenterFrequency()

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

Implements ChannelAPI.

Definition at line 116 of file wfmdemod.h.

References WFMDemodSettings::m_inputFrequencyOffset, and WFMDemod::MsgConfigureWFMDemod::m_settings.

117  {
118  (void) streamIndex;
119  (void) sinkElseSource;
121  }
qint64 m_inputFrequencyOffset
WFMDemodSettings m_settings
Definition: wfmdemod.h:192

◆ getTitle()

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

Implements ChannelAPI.

Definition at line 107 of file wfmdemod.h.

References WFMDemod::MsgConfigureWFMDemod::m_settings, and WFMDemodSettings::m_title.

107 { title = m_settings.m_title; }
WFMDemodSettings m_settings
Definition: wfmdemod.h:192

◆ handleMessage()

bool WFMDemod::handleMessage ( const Message cmd)
virtual

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

Implements BasebandSampleSink.

Definition at line 208 of file wfmdemod.cpp.

References applyAudioSampleRate(), applyChannelSettings(), applySettings(), DownChannelizer::configure(), WFMDemod::MsgConfigureChannelizer::getCenterFrequency(), WFMDemod::MsgConfigureWFMDemod::getForce(), DownChannelizer::MsgChannelizerNotification::getFrequencyOffset(), BasebandSampleSink::getInputMessageQueue(), DownChannelizer::MsgChannelizerNotification::getSampleRate(), WFMDemod::MsgConfigureChannelizer::getSampleRate(), DSPConfigureAudio::getSampleRate(), WFMDemod::MsgConfigureWFMDemod::getSettings(), BasebandSampleSink::MsgThreadedSink::getThread(), m_audioSampleRate, m_channelizer, and Message::match().

Referenced by destroy().

209 {
211  {
213  qDebug() << "WFMDemod::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << notif.getSampleRate()
214  << " m_inputFrequencyOffset: " << notif.getFrequencyOffset();
215 
217 
218  return true;
219  }
220  else if (MsgConfigureChannelizer::match(cmd))
221  {
222  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
223  qDebug() << "WFMDemod::handleMessage: MsgConfigureChannelizer:"
224  << " sampleRate: " << cfg.getSampleRate()
225  << " inputFrequencyOffset: " << cfg.getCenterFrequency();
226 
228  cfg.getSampleRate(),
229  cfg.getCenterFrequency());
230 
231  return true;
232  }
233  else if (MsgConfigureWFMDemod::match(cmd))
234  {
235  MsgConfigureWFMDemod& cfg = (MsgConfigureWFMDemod&) cmd;
236  qDebug("WFMDemod::handleMessage: MsgConfigureWFMDemod");
237 
238  applySettings(cfg.getSettings(), cfg.getForce());
239 
240  return true;
241  }
243  {
245  const QThread *thread = cfg.getThread();
246  qDebug("WFMDemod::handleMessage: BasebandSampleSink::MsgThreadedSink: %p", thread);
247  return true;
248  }
249  else if (DSPConfigureAudio::match(cmd))
250  {
251  DSPConfigureAudio& cfg = (DSPConfigureAudio&) cmd;
252  uint32_t sampleRate = cfg.getSampleRate();
253 
254  qDebug() << "WFMDemod::handleMessage: DSPConfigureAudio:"
255  << " sampleRate: " << sampleRate;
256 
257  if (sampleRate != m_audioSampleRate) {
258  applyAudioSampleRate(sampleRate);
259  }
260 
261  return true;
262  }
263  else if (DSPSignalNotification::match(cmd))
264  {
265  return true;
266  }
267  else
268  {
269  return false;
270  }
271 }
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
unsigned int uint32_t
Definition: rtptypes_win.h:46
int getSampleRate() const
Definition: dspcommands.h:390
static bool match(const Message *message)
Definition: message.cpp:45
quint32 m_audioSampleRate
Definition: wfmdemod.h:193
void applyAudioSampleRate(int sampleRate)
Definition: wfmdemod.cpp:273
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: wfmdemod.cpp:288
void applySettings(const WFMDemodSettings &settings, bool force=false)
Definition: wfmdemod.cpp:321
DownChannelizer * m_channelizer
Definition: wfmdemod.h:188
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void WFMDemod::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 645 of file wfmdemod.cpp.

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

646 {
647  QNetworkReply::NetworkError replyError = reply->error();
648 
649  if (replyError)
650  {
651  qWarning() << "WFMDemod::networkManagerFinished:"
652  << " error(" << (int) replyError
653  << "): " << replyError
654  << ": " << reply->errorString();
655  return;
656  }
657 
658  QString answer = reply->readAll();
659  answer.chop(1); // remove last \n
660  qDebug("WFMDemod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
661 }
+ Here is the caller graph for this function:

◆ requiredBW()

static int WFMDemod::requiredBW ( int  rfBW)
inlinestatic

Definition at line 158 of file wfmdemod.h.

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

159  {
160  if (rfBW <= 48000) {
161  return 48000;
162  } else {
163  return (3*rfBW)/2;
164  }
165  }
+ Here is the caller graph for this function:

◆ serialize()

QByteArray WFMDemod::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 418 of file wfmdemod.cpp.

References m_settings, and WFMDemodSettings::serialize().

Referenced by getCenterFrequency().

419 {
420  return m_settings.serialize();
421 }
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

void WFMDemod::start ( )
virtual

Implements BasebandSampleSink.

Definition at line 196 of file wfmdemod.cpp.

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

Referenced by destroy().

197 {
198  m_squelchState = 0;
199  m_audioFifo.clear();
202 }
void clear()
Definition: audiofifo.cpp:156
int m_inputSampleRate
Definition: wfmdemod.h:190
int m_squelchState
Definition: wfmdemod.h:202
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: wfmdemod.cpp:288
int m_inputFrequencyOffset
Definition: wfmdemod.h:191
AudioFifo m_audioFifo
Definition: wfmdemod.h:216
PhaseDiscriminators m_phaseDiscri
Definition: wfmdemod.h:220
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void WFMDemod::stop ( )
virtual

Implements BasebandSampleSink.

Definition at line 204 of file wfmdemod.cpp.

Referenced by destroy().

205 {
206 }
+ Here is the caller graph for this function:

◆ webapiFormatChannelReport()

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

Definition at line 574 of file wfmdemod.cpp.

References CalcDb::dbPower(), getMagSqLevels(), SWGSDRangel::SWGChannelReport::getWfmDemodReport(), m_audioSampleRate, m_inputSampleRate, m_squelchState, SWGSDRangel::SWGWFMDemodReport::setAudioSampleRate(), SWGSDRangel::SWGWFMDemodReport::setChannelPowerDb(), SWGSDRangel::SWGWFMDemodReport::setChannelSampleRate(), and SWGSDRangel::SWGWFMDemodReport::setSquelch().

Referenced by webapiReportGet().

575 {
576  double magsqAvg, magsqPeak;
577  int nbMagsqSamples;
578  getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
579 
580  response.getWfmDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg));
581  response.getWfmDemodReport()->setSquelch(m_squelchState > 0 ? 1 : 0);
584 }
void setChannelSampleRate(qint32 channel_sample_rate)
static double dbPower(double magsq, double floor=1e-12)
Definition: db.cpp:22
int m_inputSampleRate
Definition: wfmdemod.h:190
int m_squelchState
Definition: wfmdemod.h:202
SWGWFMDemodReport * getWfmDemodReport()
void getMagSqLevels(double &avg, double &peak, int &nbSamples)
Definition: wfmdemod.h:126
quint32 m_audioSampleRate
Definition: wfmdemod.h:193
void setAudioSampleRate(qint32 audio_sample_rate)
void setChannelPowerDb(float channel_power_db)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatChannelSettings()

void WFMDemod::webapiFormatChannelSettings ( SWGSDRangel::SWGChannelSettings response,
const WFMDemodSettings settings 
)
private

Definition at line 539 of file wfmdemod.cpp.

References SWGSDRangel::SWGWFMDemodSettings::getAudioDeviceName(), SWGSDRangel::SWGWFMDemodSettings::getReverseApiAddress(), SWGSDRangel::SWGWFMDemodSettings::getTitle(), SWGSDRangel::SWGChannelSettings::getWfmDemodSettings(), WFMDemodSettings::m_afBandwidth, WFMDemodSettings::m_audioDeviceName, WFMDemodSettings::m_audioMute, WFMDemodSettings::m_inputFrequencyOffset, WFMDemodSettings::m_reverseAPIAddress, WFMDemodSettings::m_reverseAPIChannelIndex, WFMDemodSettings::m_reverseAPIDeviceIndex, WFMDemodSettings::m_reverseAPIPort, WFMDemodSettings::m_rfBandwidth, WFMDemodSettings::m_rgbColor, WFMDemodSettings::m_squelch, WFMDemodSettings::m_title, WFMDemodSettings::m_useReverseAPI, WFMDemodSettings::m_volume, SWGSDRangel::SWGWFMDemodSettings::setAfBandwidth(), SWGSDRangel::SWGWFMDemodSettings::setAudioDeviceName(), SWGSDRangel::SWGWFMDemodSettings::setAudioMute(), SWGSDRangel::SWGWFMDemodSettings::setInputFrequencyOffset(), SWGSDRangel::SWGWFMDemodSettings::setReverseApiAddress(), SWGSDRangel::SWGWFMDemodSettings::setReverseApiChannelIndex(), SWGSDRangel::SWGWFMDemodSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGWFMDemodSettings::setReverseApiPort(), SWGSDRangel::SWGWFMDemodSettings::setRfBandwidth(), SWGSDRangel::SWGWFMDemodSettings::setRgbColor(), SWGSDRangel::SWGWFMDemodSettings::setSquelch(), SWGSDRangel::SWGWFMDemodSettings::setTitle(), SWGSDRangel::SWGWFMDemodSettings::setUseReverseApi(), and SWGSDRangel::SWGWFMDemodSettings::setVolume().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

540 {
542  response.getWfmDemodSettings()->setRfBandwidth(settings.m_rfBandwidth);
543  response.getWfmDemodSettings()->setAfBandwidth(settings.m_afBandwidth);
544  response.getWfmDemodSettings()->setVolume(settings.m_volume);
545  response.getWfmDemodSettings()->setSquelch(settings.m_squelch);
546  response.getWfmDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
547  response.getWfmDemodSettings()->setRgbColor(settings.m_rgbColor);
548 
549  if (response.getWfmDemodSettings()->getTitle()) {
550  *response.getWfmDemodSettings()->getTitle() = settings.m_title;
551  } else {
552  response.getWfmDemodSettings()->setTitle(new QString(settings.m_title));
553  }
554 
555  if (response.getWfmDemodSettings()->getAudioDeviceName()) {
556  *response.getWfmDemodSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
557  } else {
558  response.getWfmDemodSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
559  }
560 
561  response.getWfmDemodSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
562 
563  if (response.getWfmDemodSettings()->getReverseApiAddress()) {
565  } else {
566  response.getWfmDemodSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
567  }
568 
572 }
void setReverseApiAddress(QString *reverse_api_address)
qint64 m_inputFrequencyOffset
uint16_t m_reverseAPIPort
uint16_t m_reverseAPIChannelIndex
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
SWGWFMDemodSettings * getWfmDemodSettings()
uint16_t m_reverseAPIDeviceIndex
QString m_reverseAPIAddress
void setReverseApiPort(qint32 reverse_api_port)
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setAfBandwidth(float af_bandwidth)
void setRfBandwidth(float rf_bandwidth)
void setUseReverseApi(qint32 use_reverse_api)
void setAudioDeviceName(QString *audio_device_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from ChannelAPI.

Definition at line 528 of file wfmdemod.cpp.

References SWGSDRangel::SWGChannelReport::getWfmDemodReport(), SWGSDRangel::SWGWFMDemodReport::init(), SWGSDRangel::SWGChannelReport::setWfmDemodReport(), and webapiFormatChannelReport().

Referenced by getMagSqLevels().

531 {
532  (void) errorMessage;
534  response.getWfmDemodReport()->init();
535  webapiFormatChannelReport(response);
536  return 200;
537 }
SWGWFMDemodReport * getWfmDemodReport()
void setWfmDemodReport(SWGWFMDemodReport *wfm_demod_report)
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
Definition: wfmdemod.cpp:574
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 586 of file wfmdemod.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), ChannelAPI::getDeviceSetIndex(), ChannelAPI::getIndexInDeviceSet(), SWGSDRangel::SWGChannelSettings::getWfmDemodSettings(), WFMDemodSettings::m_afBandwidth, WFMDemodSettings::m_audioDeviceName, WFMDemodSettings::m_audioMute, WFMDemodSettings::m_inputFrequencyOffset, m_networkManager, m_networkRequest, WFMDemodSettings::m_reverseAPIAddress, WFMDemodSettings::m_reverseAPIChannelIndex, WFMDemodSettings::m_reverseAPIDeviceIndex, WFMDemodSettings::m_reverseAPIPort, WFMDemodSettings::m_rfBandwidth, WFMDemodSettings::m_rgbColor, WFMDemodSettings::m_squelch, WFMDemodSettings::m_title, WFMDemodSettings::m_volume, SWGSDRangel::SWGWFMDemodSettings::setAfBandwidth(), SWGSDRangel::SWGWFMDemodSettings::setAudioDeviceName(), SWGSDRangel::SWGWFMDemodSettings::setAudioMute(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGWFMDemodSettings::setInputFrequencyOffset(), SWGSDRangel::SWGChannelSettings::setOriginatorChannelIndex(), SWGSDRangel::SWGChannelSettings::setOriginatorDeviceSetIndex(), SWGSDRangel::SWGWFMDemodSettings::setRfBandwidth(), SWGSDRangel::SWGWFMDemodSettings::setRgbColor(), SWGSDRangel::SWGWFMDemodSettings::setSquelch(), SWGSDRangel::SWGWFMDemodSettings::setTitle(), SWGSDRangel::SWGWFMDemodSettings::setVolume(), and SWGSDRangel::SWGChannelSettings::setWfmDemodSettings().

Referenced by applySettings().

587 {
589  swgChannelSettings->setDirection(0); // single sink (Rx)
590  swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
591  swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
592  swgChannelSettings->setChannelType(new QString("WFMDemod"));
593  swgChannelSettings->setWfmDemodSettings(new SWGSDRangel::SWGWFMDemodSettings());
594  SWGSDRangel::SWGWFMDemodSettings *swgWFMDemodSettings = swgChannelSettings->getWfmDemodSettings();
595 
596  // transfer data that has been modified. When force is on transfer all data except reverse API data
597 
598  if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
599  swgWFMDemodSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
600  }
601  if (channelSettingsKeys.contains("rfBandwidth") || force) {
602  swgWFMDemodSettings->setRfBandwidth(settings.m_rfBandwidth);
603  }
604  if (channelSettingsKeys.contains("afBandwidth") || force) {
605  swgWFMDemodSettings->setAfBandwidth(settings.m_afBandwidth);
606  }
607  if (channelSettingsKeys.contains("volume") || force) {
608  swgWFMDemodSettings->setVolume(settings.m_volume);
609  }
610  if (channelSettingsKeys.contains("squelch") || force) {
611  swgWFMDemodSettings->setSquelch(settings.m_squelch);
612  }
613  if (channelSettingsKeys.contains("audioMute") || force) {
614  swgWFMDemodSettings->setAudioMute(settings.m_audioMute ? 1 : 0);
615  }
616  if (channelSettingsKeys.contains("rgbColor") || force) {
617  swgWFMDemodSettings->setRgbColor(settings.m_rgbColor);
618  }
619  if (channelSettingsKeys.contains("title") || force) {
620  swgWFMDemodSettings->setTitle(new QString(settings.m_title));
621  }
622  if (channelSettingsKeys.contains("audioDeviceName") || force) {
623  swgWFMDemodSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
624  }
625 
626  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
627  .arg(settings.m_reverseAPIAddress)
628  .arg(settings.m_reverseAPIPort)
629  .arg(settings.m_reverseAPIDeviceIndex)
630  .arg(settings.m_reverseAPIChannelIndex);
631  m_networkRequest.setUrl(QUrl(channelSettingsURL));
632  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
633 
634  QBuffer *buffer=new QBuffer();
635  buffer->open((QBuffer::ReadWrite));
636  buffer->write(swgChannelSettings->asJson().toUtf8());
637  buffer->seek(0);
638 
639  // Always use PATCH to avoid passing reverse API settings
640  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
641 
642  delete swgChannelSettings;
643 }
void setOriginatorChannelIndex(qint32 originator_channel_index)
qint64 m_inputFrequencyOffset
void setWfmDemodSettings(SWGWFMDemodSettings *wfm_demod_settings)
uint16_t m_reverseAPIPort
int getDeviceSetIndex() const
Definition: channelapi.h:89
uint16_t m_reverseAPIChannelIndex
void setChannelType(QString *channel_type)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
SWGWFMDemodSettings * getWfmDemodSettings()
uint16_t m_reverseAPIDeviceIndex
QString m_reverseAPIAddress
QNetworkRequest m_networkRequest
Definition: wfmdemod.h:223
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setAfBandwidth(float af_bandwidth)
QNetworkAccessManager * m_networkManager
Definition: wfmdemod.h:222
virtual QString asJson() override
void setRfBandwidth(float rf_bandwidth)
int getIndexInDeviceSet() const
Definition: channelapi.h:87
void setAudioDeviceName(QString *audio_device_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from ChannelAPI.

Definition at line 440 of file wfmdemod.cpp.

References SWGSDRangel::SWGChannelSettings::getWfmDemodSettings(), SWGSDRangel::SWGWFMDemodSettings::init(), m_settings, SWGSDRangel::SWGChannelSettings::setWfmDemodSettings(), and webapiFormatChannelSettings().

Referenced by getMagSqLevels().

443 {
444  (void) errorMessage;
446  response.getWfmDemodSettings()->init();
448  return 200;
449 }
void setWfmDemodSettings(SWGWFMDemodSettings *wfm_demod_settings)
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
SWGWFMDemodSettings * getWfmDemodSettings()
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const WFMDemodSettings &settings)
Definition: wfmdemod.cpp:539
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from ChannelAPI.

Definition at line 451 of file wfmdemod.cpp.

References WFMDemod::MsgConfigureWFMDemod::create(), WFMDemod::MsgConfigureChannelizer::create(), SWGSDRangel::SWGWFMDemodSettings::getAfBandwidth(), SWGSDRangel::SWGWFMDemodSettings::getAudioDeviceName(), SWGSDRangel::SWGWFMDemodSettings::getAudioMute(), SWGSDRangel::SWGWFMDemodSettings::getInputFrequencyOffset(), SWGSDRangel::SWGWFMDemodSettings::getReverseApiAddress(), SWGSDRangel::SWGWFMDemodSettings::getReverseApiChannelIndex(), SWGSDRangel::SWGWFMDemodSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGWFMDemodSettings::getReverseApiPort(), SWGSDRangel::SWGWFMDemodSettings::getRfBandwidth(), SWGSDRangel::SWGWFMDemodSettings::getRgbColor(), SWGSDRangel::SWGWFMDemodSettings::getSquelch(), SWGSDRangel::SWGWFMDemodSettings::getTitle(), SWGSDRangel::SWGWFMDemodSettings::getUseReverseApi(), SWGSDRangel::SWGWFMDemodSettings::getVolume(), SWGSDRangel::SWGChannelSettings::getWfmDemodSettings(), WFMDemodSettings::m_afBandwidth, WFMDemodSettings::m_audioDeviceName, WFMDemodSettings::m_audioMute, BasebandSampleSink::m_guiMessageQueue, WFMDemodSettings::m_inputFrequencyOffset, BasebandSampleSink::m_inputMessageQueue, WFMDemodSettings::m_reverseAPIAddress, WFMDemodSettings::m_reverseAPIChannelIndex, WFMDemodSettings::m_reverseAPIDeviceIndex, WFMDemodSettings::m_reverseAPIPort, WFMDemodSettings::m_rfBandwidth, WFMDemodSettings::m_rgbColor, m_settings, WFMDemodSettings::m_squelch, WFMDemodSettings::m_title, WFMDemodSettings::m_useReverseAPI, WFMDemodSettings::m_volume, MessageQueue::push(), requiredBW(), and webapiFormatChannelSettings().

Referenced by getMagSqLevels().

456 {
457  (void) errorMessage;
458  WFMDemodSettings settings = m_settings;
459  bool frequencyOffsetChanged = false;
460 
461  if (channelSettingsKeys.contains("inputFrequencyOffset"))
462  {
464  frequencyOffsetChanged = true;
465  }
466  if (channelSettingsKeys.contains("rfBandwidth")) {
467  settings.m_rfBandwidth = response.getWfmDemodSettings()->getRfBandwidth();
468  }
469  if (channelSettingsKeys.contains("afBandwidth")) {
470  settings.m_afBandwidth = response.getWfmDemodSettings()->getAfBandwidth();
471  }
472  if (channelSettingsKeys.contains("volume")) {
473  settings.m_volume = response.getWfmDemodSettings()->getVolume();
474  }
475  if (channelSettingsKeys.contains("squelch")) {
476  settings.m_squelch = response.getWfmDemodSettings()->getSquelch();
477  }
478  if (channelSettingsKeys.contains("audioMute")) {
479  settings.m_audioMute = response.getWfmDemodSettings()->getAudioMute() != 0;
480  }
481  if (channelSettingsKeys.contains("rgbColor")) {
482  settings.m_rgbColor = response.getWfmDemodSettings()->getRgbColor();
483  }
484  if (channelSettingsKeys.contains("title")) {
485  settings.m_title = *response.getWfmDemodSettings()->getTitle();
486  }
487  if (channelSettingsKeys.contains("audioDeviceName")) {
488  settings.m_audioDeviceName = *response.getWfmDemodSettings()->getAudioDeviceName();
489  }
490  if (channelSettingsKeys.contains("useReverseAPI")) {
491  settings.m_useReverseAPI = response.getWfmDemodSettings()->getUseReverseApi() != 0;
492  }
493  if (channelSettingsKeys.contains("reverseAPIAddress")) {
495  }
496  if (channelSettingsKeys.contains("reverseAPIPort")) {
497  settings.m_reverseAPIPort = response.getWfmDemodSettings()->getReverseApiPort();
498  }
499  if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
501  }
502  if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
504  }
505 
506  if (frequencyOffsetChanged)
507  {
508  MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
509  requiredBW(settings.m_rfBandwidth), settings.m_inputFrequencyOffset);
510  m_inputMessageQueue.push(channelConfigMsg);
511  }
512 
513  MsgConfigureWFMDemod *msg = MsgConfigureWFMDemod::create(settings, force);
515 
516  qDebug("WFMDemod::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
517  if (m_guiMessageQueue) // forward to GUI if any
518  {
519  MsgConfigureWFMDemod *msgToGUI = MsgConfigureWFMDemod::create(settings, force);
520  m_guiMessageQueue->push(msgToGUI);
521  }
522 
523  webapiFormatChannelSettings(response, settings);
524 
525  return 200;
526 }
qint64 m_inputFrequencyOffset
void push(Message *message, bool emitSignal=true)
Push message onto queue.
WFMDemodSettings m_settings
Definition: wfmdemod.h:192
uint16_t m_reverseAPIPort
uint16_t m_reverseAPIChannelIndex
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
SWGWFMDemodSettings * getWfmDemodSettings()
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
uint16_t m_reverseAPIDeviceIndex
static int requiredBW(int rfBW)
Definition: wfmdemod.h:158
QString m_reverseAPIAddress
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: wfmdemod.h:81
static MsgConfigureWFMDemod * create(const WFMDemodSettings &settings, bool force)
Definition: wfmdemod.h:58
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const WFMDemodSettings &settings)
Definition: wfmdemod.cpp:539
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_audioBuffer

AudioVector WFMDemod::m_audioBuffer
private

Definition at line 213 of file wfmdemod.h.

Referenced by feed(), and WFMDemod().

◆ m_audioBufferFill

uint WFMDemod::m_audioBufferFill
private

Definition at line 214 of file wfmdemod.h.

Referenced by feed(), and WFMDemod().

◆ m_audioFifo

AudioFifo WFMDemod::m_audioFifo
private

Definition at line 216 of file wfmdemod.h.

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

◆ m_audioSampleRate

quint32 WFMDemod::m_audioSampleRate
private

◆ m_channelId

const QString WFMDemod::m_channelId = "WFMDemod"
static

Definition at line 168 of file wfmdemod.h.

Referenced by WFMPlugin::initPlugin(), and WFMDemod().

◆ m_channelIdURI

const QString WFMDemod::m_channelIdURI = "sdrangel.channel.wfmdemod"
static

Definition at line 167 of file wfmdemod.h.

Referenced by WFMPlugin::initPlugin(), and WFMDemodGUI::WFMDemodGUI().

◆ m_channelizer

DownChannelizer* WFMDemod::m_channelizer
private

Definition at line 188 of file wfmdemod.h.

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

◆ m_deviceAPI

DeviceAPI* WFMDemod::m_deviceAPI
private

Definition at line 186 of file wfmdemod.h.

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

◆ m_fmExcursion

Real WFMDemod::m_fmExcursion
private

Definition at line 211 of file wfmdemod.h.

Referenced by applyChannelSettings(), and applySettings().

◆ m_inputFrequencyOffset

int WFMDemod::m_inputFrequencyOffset
private

Definition at line 191 of file wfmdemod.h.

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

◆ m_inputSampleRate

int WFMDemod::m_inputSampleRate
private

◆ m_interpolator

Interpolator WFMDemod::m_interpolator
private

Interpolator between sample rate sent from DSP engine and requested RF bandwidth (rational)

Definition at line 196 of file wfmdemod.h.

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

◆ m_interpolatorDistance

Real WFMDemod::m_interpolatorDistance
private

Definition at line 197 of file wfmdemod.h.

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

◆ m_interpolatorDistanceRemain

Real WFMDemod::m_interpolatorDistanceRemain
private

Definition at line 198 of file wfmdemod.h.

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

◆ m_magsq

double WFMDemod::m_magsq
private

displayed averaged value

Definition at line 204 of file wfmdemod.h.

Referenced by getMagSqLevels().

◆ m_magsqCount

int WFMDemod::m_magsqCount
private

Definition at line 207 of file wfmdemod.h.

Referenced by feed(), and getMagSqLevels().

◆ m_magSqLevelStore

MagSqLevelsStore WFMDemod::m_magSqLevelStore
private

Definition at line 208 of file wfmdemod.h.

Referenced by getMagSqLevels().

◆ m_magsqPeak

double WFMDemod::m_magsqPeak
private

Definition at line 206 of file wfmdemod.h.

Referenced by feed(), and getMagSqLevels().

◆ m_magsqSum

double WFMDemod::m_magsqSum
private

Definition at line 205 of file wfmdemod.h.

Referenced by feed(), and getMagSqLevels().

◆ m_movingAverage

MovingAverageUtil<Real, double, 16> WFMDemod::m_movingAverage
private

Definition at line 210 of file wfmdemod.h.

Referenced by feed(), and getMagSq().

◆ m_nco

NCO WFMDemod::m_nco
private

Definition at line 195 of file wfmdemod.h.

Referenced by applyChannelSettings(), and feed().

◆ m_networkManager

QNetworkAccessManager* WFMDemod::m_networkManager
private

Definition at line 222 of file wfmdemod.h.

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

◆ m_networkRequest

QNetworkRequest WFMDemod::m_networkRequest
private

Definition at line 223 of file wfmdemod.h.

Referenced by webapiReverseSendSettings().

◆ m_phaseDiscri

PhaseDiscriminators WFMDemod::m_phaseDiscri
private

Definition at line 220 of file wfmdemod.h.

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

◆ m_rfFilter

fftfilt* WFMDemod::m_rfFilter
private

Definition at line 199 of file wfmdemod.h.

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

◆ m_sampleBuffer

SampleVector WFMDemod::m_sampleBuffer
private

Definition at line 217 of file wfmdemod.h.

Referenced by feed().

◆ m_settings

WFMDemodSettings WFMDemod::m_settings
private

◆ m_settingsMutex

QMutex WFMDemod::m_settingsMutex
private

Definition at line 218 of file wfmdemod.h.

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

◆ m_squelchLevel

Real WFMDemod::m_squelchLevel
private

Definition at line 201 of file wfmdemod.h.

Referenced by applySettings(), and feed().

◆ m_squelchOpen

bool WFMDemod::m_squelchOpen
private

Definition at line 203 of file wfmdemod.h.

Referenced by feed(), and getSquelchOpen().

◆ m_squelchState

int WFMDemod::m_squelchState
private

Definition at line 202 of file wfmdemod.h.

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

◆ m_threadedChannelizer

ThreadedBasebandSampleSink* WFMDemod::m_threadedChannelizer
private

Definition at line 187 of file wfmdemod.h.

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

◆ m_udpBlockSize

const int WFMDemod::m_udpBlockSize = 512
staticprivate

Definition at line 225 of file wfmdemod.h.


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