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 Attributes | Private Types | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
AMDemod Class Reference

#include <amdemod.h>

+ Inheritance diagram for AMDemod:
+ Collaboration diagram for AMDemod:

Classes

struct  MagSqLevelsStore
 
class  MsgConfigureAMDemod
 
class  MsgConfigureChannelizer
 

Public Member Functions

 AMDemod (DeviceAPI *deviceAPI)
 
 ~AMDemod ()
 
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
 
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)
 
uint32_t getAudioSampleRate () const
 
double getMagSq () const
 
bool getSquelchOpen () const
 
bool getPllLocked () const
 
Real getPllFrequency () const
 
void getMagSqLevels (double &avg, double &peak, int &nbSamples)
 
uint32_t getNumberOfDeviceStreams () const
 
- 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 Attributes

static const QString m_channelIdURI = "sdrangel.channel.amdemod"
 
static const QString m_channelId = "AMDemod"
 

Private Types

enum  RateState { RSInitialFill, RSRunning }
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void applyChannelSettings (int inputSampleRate, int inputFrequencyOffset, bool force=false)
 
void applySettings (const AMDemodSettings &settings, bool force=false)
 
void applyAudioSampleRate (int sampleRate)
 
void webapiFormatChannelSettings (SWGSDRangel::SWGChannelSettings &response, const AMDemodSettings &settings)
 
void webapiFormatChannelReport (SWGSDRangel::SWGChannelReport &response)
 
void webapiReverseSendSettings (QList< QString > &channelSettingsKeys, const AMDemodSettings &settings, bool force)
 
void processOneSample (Complex &ci)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSinkm_threadedChannelizer
 
DownChannelizerm_channelizer
 
int m_inputSampleRate
 
int m_inputFrequencyOffset
 
AMDemodSettings m_settings
 
uint32_t m_audioSampleRate
 
bool m_running
 
NCO m_nco
 
Interpolator m_interpolator
 
Real m_interpolatorDistance
 
Real m_interpolatorDistanceRemain
 
Real m_squelchLevel
 
uint32_t m_squelchCount
 
bool m_squelchOpen
 
DoubleBufferFIFO< Realm_squelchDelayLine
 
double m_magsq
 
double m_magsqSum
 
double m_magsqPeak
 
int m_magsqCount
 
MagSqLevelsStore m_magSqLevelStore
 
MovingAverageUtil< Real, double, 16 > m_movingAverage
 
SimpleAGC< 4800 > m_volumeAGC
 
Bandpass< Realm_bandpass
 
Lowpass< Realm_lowpass
 
Lowpass< std::complex< float > > m_pllFilt
 
PhaseLockComplex m_pll
 
fftfiltDSBFilter
 
fftfiltSSBFilter
 
Real m_syncAMBuff [2 *1024]
 
uint32_t m_syncAMBuffIndex
 
MagAGC m_syncAMAGC
 
AudioVector m_audioBuffer
 
uint32_t m_audioBufferFill
 
AudioFifo m_audioFifo
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 
QMutex m_settingsMutex
 

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 amdemod.h.

Member Enumeration Documentation

◆ RateState

enum AMDemod::RateState
private
Enumerator
RSInitialFill 
RSRunning 

Definition at line 177 of file amdemod.h.

Constructor & Destructor Documentation

◆ AMDemod()

AMDemod::AMDemod ( DeviceAPI deviceAPI)

Definition at line 52 of file amdemod.cpp.

References AudioDeviceManager::addAudioSink(), DeviceAPI::addChannelSink(), DeviceAPI::addChannelSinkAPI(), applyChannelSettings(), applySettings(), PhaseLockComplex::computeCoefficients(), Lowpass< Type >::create(), DSBFilter, 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_magsq, m_networkManager, m_pll, m_pllFilt, AMDemodSettings::m_rfBandwidth, m_settings, m_syncAMAGC, m_syncAMBuffIndex, m_threadedChannelizer, networkManagerFinished(), MagAGC::resize(), MagAGC::setThresholdEnable(), and SSBFilter.

Referenced by AMDemod::MsgConfigureChannelizer::MsgConfigureChannelizer().

52  :
54  m_deviceAPI(deviceAPI),
55  m_inputSampleRate(48000),
57  m_running(false),
58  m_squelchOpen(false),
59  m_squelchDelayLine(9600),
60  m_magsqSum(0.0f),
61  m_magsqPeak(0.0f),
62  m_magsqCount(0),
63  m_volumeAGC(0.003),
64  m_syncAMAGC(12000, 0.1, 1e-2),
65  m_audioFifo(48000),
66  m_settingsMutex(QMutex::Recursive)
67 {
68  setObjectName(m_channelId);
69 
70  m_audioBuffer.resize(1<<14);
72 
73  m_magsq = 0.0;
74 
77  DSBFilter = new fftfilt((2.0f * m_settings.m_rfBandwidth) / m_audioSampleRate, 2 * 1024);
80  m_syncAMAGC.resize(12000, 6000, 0.1);
81 
84 
85  m_channelizer = new DownChannelizer(this);
89 
90  m_pllFilt.create(101, m_audioSampleRate, 200.0);
91  m_pll.computeCoefficients(0.05, 0.707, 1000);
93 
94  m_networkManager = new QNetworkAccessManager();
95  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
96 }
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: amdemod.cpp:410
int getOutputSampleRate(int outputDeviceIndex=-1)
int m_magsqCount
Definition: amdemod.h:204
QNetworkAccessManager * m_networkManager
Definition: amdemod.h:225
MagAGC m_syncAMAGC
Definition: amdemod.h:217
double m_magsqSum
Definition: amdemod.h:202
void setThresholdEnable(bool enable)
Definition: agc.cpp:83
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
AMDemodSettings m_settings
Definition: amdemod.h:188
void create(int nTaps, double sampleRate, double cutoff)
Definition: lowpass.h:15
DeviceAPI * m_deviceAPI
Definition: amdemod.h:182
double m_magsq
Definition: amdemod.h:201
fftfilt * SSBFilter
Definition: amdemod.h:214
bool m_running
Definition: amdemod.h:190
AudioFifo m_audioFifo
Definition: amdemod.h:221
fftfilt * DSBFilter
Definition: amdemod.h:213
void resize(int historySize, int stepLength, Real R)
Definition: agc.cpp:65
QMutex m_settingsMutex
Definition: amdemod.h:228
static DSPEngine * instance()
Definition: dspengine.cpp:51
int m_inputFrequencyOffset
Definition: amdemod.h:187
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
uint32_t m_audioSampleRate
Definition: amdemod.h:189
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: amdemod.h:183
DoubleBufferFIFO< Real > m_squelchDelayLine
Definition: amdemod.h:200
DownChannelizer * m_channelizer
Definition: amdemod.h:184
int m_inputSampleRate
Definition: amdemod.h:186
double m_magsqPeak
Definition: amdemod.h:203
void applySettings(const AMDemodSettings &settings, bool force=false)
Definition: amdemod.cpp:436
static const QString m_channelId
Definition: amdemod.h:164
Exposes a single sink stream (input, Rx)
Definition: channelapi.h:41
Lowpass< std::complex< float > > m_pllFilt
Definition: amdemod.h:211
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
AudioVector m_audioBuffer
Definition: amdemod.h:219
uint32_t m_audioBufferFill
Definition: amdemod.h:220
PhaseLockComplex m_pll
Definition: amdemod.h:212
void networkManagerFinished(QNetworkReply *reply)
Definition: amdemod.cpp:816
void computeCoefficients(Real wn, Real zeta, Real K)
uint32_t m_syncAMBuffIndex
Definition: amdemod.h:216
static const QString m_channelIdURI
Definition: amdemod.h:163
bool m_squelchOpen
Definition: amdemod.h:199
SimpleAGC< 4800 > m_volumeAGC
Definition: amdemod.h:208
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~AMDemod()

AMDemod::~AMDemod ( )

Definition at line 98 of file amdemod.cpp.

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

Referenced by AMDemod::MsgConfigureChannelizer::MsgConfigureChannelizer().

99 {
100  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
101  delete m_networkManager;
105  delete m_threadedChannelizer;
106  delete m_channelizer;
107  delete DSBFilter;
108  delete SSBFilter;
109 }
QNetworkAccessManager * m_networkManager
Definition: amdemod.h:225
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
DeviceAPI * m_deviceAPI
Definition: amdemod.h:182
void removeAudioSink(AudioFifo *audioFifo)
Remove the audio sink.
fftfilt * SSBFilter
Definition: amdemod.h:214
AudioFifo m_audioFifo
Definition: amdemod.h:221
fftfilt * DSBFilter
Definition: amdemod.h:213
static DSPEngine * instance()
Definition: dspengine.cpp:51
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: amdemod.h:183
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
DownChannelizer * m_channelizer
Definition: amdemod.h:184
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
void networkManagerFinished(QNetworkReply *reply)
Definition: amdemod.cpp:816
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applyAudioSampleRate()

void AMDemod::applyAudioSampleRate ( int  sampleRate)
private

Definition at line 377 of file amdemod.cpp.

References Bandpass< Type >::create(), Lowpass< Type >::create(), Interpolator::create(), AMDemod::MsgConfigureChannelizer::create(), fftfilt::create_dsb_filter(), DSBFilter, m_audioFifo, m_audioSampleRate, m_bandpass, AMDemodSettings::m_inputFrequencyOffset, BasebandSampleSink::m_inputMessageQueue, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_lowpass, AMDemodSettings::m_pll, m_pll, m_pllFilt, AMDemodSettings::m_rfBandwidth, m_settings, m_settingsMutex, m_squelchDelayLine, m_syncAMAGC, m_volumeAGC, MessageQueue::push(), DoubleBufferFIFO< T >::resize(), MagAGC::resize(), SimpleAGC< AvgSize >::resizeNew(), PhaseLockComplex::setSampleRate(), and AudioFifo::setSize().

Referenced by applySettings(), and handleMessage().

378 {
379  qDebug("AMDemod::applyAudioSampleRate: sampleRate: %d m_inputSampleRate: %d", sampleRate, m_inputSampleRate);
380 
381  MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
382  sampleRate, m_settings.m_inputFrequencyOffset);
383  m_inputMessageQueue.push(channelConfigMsg);
384 
385  m_settingsMutex.lock();
386 
390  m_bandpass.create(301, sampleRate, 300.0, m_settings.m_rfBandwidth / 2.0f);
391  m_lowpass.create(301, sampleRate, m_settings.m_rfBandwidth / 2.0f);
392  m_audioFifo.setSize(sampleRate);
393  m_squelchDelayLine.resize(sampleRate/5);
394  DSBFilter->create_dsb_filter((2.0f * m_settings.m_rfBandwidth) / (float) sampleRate);
395  m_pllFilt.create(101, sampleRate, 200.0);
396 
397  if (m_settings.m_pll) {
398  m_volumeAGC.resizeNew(sampleRate, 0.003);
399  } else {
400  m_volumeAGC.resizeNew(sampleRate/10, 0.003);
401  }
402 
403  m_syncAMAGC.resize(sampleRate/4, sampleRate/8, 0.1);
404  m_pll.setSampleRate(sampleRate);
405 
406  m_settingsMutex.unlock();
407  m_audioSampleRate = sampleRate;
408 }
void resize(int size)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MagAGC m_syncAMAGC
Definition: amdemod.h:217
void create(int nTaps, double sampleRate, double lowCutoff, double highCutoff)
Definition: bandpass.h:15
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
AMDemodSettings m_settings
Definition: amdemod.h:188
void create(int nTaps, double sampleRate, double cutoff)
Definition: lowpass.h:15
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
AudioFifo m_audioFifo
Definition: amdemod.h:221
fftfilt * DSBFilter
Definition: amdemod.h:213
void resize(int historySize, int stepLength, Real R)
Definition: agc.cpp:65
Real m_interpolatorDistance
Definition: amdemod.h:194
QMutex m_settingsMutex
Definition: amdemod.h:228
Lowpass< Real > m_lowpass
Definition: amdemod.h:210
Interpolator m_interpolator
Definition: amdemod.h:193
uint32_t m_audioSampleRate
Definition: amdemod.h:189
DoubleBufferFIFO< Real > m_squelchDelayLine
Definition: amdemod.h:200
int m_inputSampleRate
Definition: amdemod.h:186
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: amdemod.h:81
Lowpass< std::complex< float > > m_pllFilt
Definition: amdemod.h:211
bool setSize(uint32_t numSamples)
Definition: audiofifo.cpp:59
void resizeNew(uint32_t newSize, Real initial, Real cutoff=0, Real clip=0)
Definition: agc.h:95
PhaseLockComplex m_pll
Definition: amdemod.h:212
qint32 m_inputFrequencyOffset
Bandpass< Real > m_bandpass
Definition: amdemod.h:209
Real m_interpolatorDistanceRemain
Definition: amdemod.h:195
float Real
Definition: dsptypes.h:42
SimpleAGC< 4800 > m_volumeAGC
Definition: amdemod.h:208
void create_dsb_filter(float f2)
Definition: fftfilt.cpp:148
void setSampleRate(unsigned int sampleRate)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyChannelSettings()

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

Definition at line 410 of file amdemod.cpp.

References Interpolator::create(), m_audioSampleRate, m_inputFrequencyOffset, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_nco, AMDemodSettings::m_rfBandwidth, m_settings, m_settingsMutex, and NCO::setFreq().

Referenced by AMDemod(), applySettings(), handleMessage(), and start().

411 {
412  qDebug() << "AMDemod::applyChannelSettings:"
413  << " inputSampleRate: " << inputSampleRate
414  << " inputFrequencyOffset: " << inputFrequencyOffset
415  << " m_audioSampleRate: " << m_audioSampleRate;
416 
417  if ((m_inputFrequencyOffset != inputFrequencyOffset) ||
418  (m_inputSampleRate != inputSampleRate) || force)
419  {
420  m_nco.setFreq(-inputFrequencyOffset, inputSampleRate);
421  }
422 
423  if ((m_inputSampleRate != inputSampleRate) || force)
424  {
425  m_settingsMutex.lock();
426  m_interpolator.create(16, inputSampleRate, m_settings.m_rfBandwidth / 2.2f);
428  m_interpolatorDistance = (Real) inputSampleRate / (Real) m_audioSampleRate;
429  m_settingsMutex.unlock();
430  }
431 
432  m_inputSampleRate = inputSampleRate;
433  m_inputFrequencyOffset = inputFrequencyOffset;
434 }
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
AMDemodSettings m_settings
Definition: amdemod.h:188
Real m_interpolatorDistance
Definition: amdemod.h:194
QMutex m_settingsMutex
Definition: amdemod.h:228
int m_inputFrequencyOffset
Definition: amdemod.h:187
Interpolator m_interpolator
Definition: amdemod.h:193
uint32_t m_audioSampleRate
Definition: amdemod.h:189
void setFreq(Real freq, Real sampleRate)
Definition: nco.cpp:49
int m_inputSampleRate
Definition: amdemod.h:186
NCO m_nco
Definition: amdemod.h:192
Real m_interpolatorDistanceRemain
Definition: amdemod.h:195
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySettings()

void AMDemod::applySettings ( const AMDemodSettings settings,
bool  force = false 
)
private

Definition at line 436 of file amdemod.cpp.

References AudioDeviceManager::addAudioSink(), DeviceAPI::addChannelSink(), DeviceAPI::addChannelSinkAPI(), applyAudioSampleRate(), applyChannelSettings(), Bandpass< Type >::create(), Lowpass< Type >::create(), Interpolator::create(), fftfilt::create_dsb_filter(), DSBFilter, DSPEngine::getAudioDeviceManager(), BasebandSampleSink::getInputMessageQueue(), AudioDeviceManager::getOutputDeviceIndex(), AudioDeviceManager::getOutputSampleRate(), DeviceAPI::getSampleMIMO(), DeviceSampleMIMO::getSourceSampleRate(), DSPEngine::instance(), AMDemodSettings::m_audioDeviceName, m_audioFifo, AMDemodSettings::m_audioMute, m_audioSampleRate, m_bandpass, AMDemodSettings::m_bandpassEnable, m_deviceAPI, AMDemodSettings::m_inputFrequencyOffset, m_inputFrequencyOffset, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_lowpass, AMDemodSettings::m_pll, AMDemodSettings::m_reverseAPIAddress, AMDemodSettings::m_reverseAPIChannelIndex, AMDemodSettings::m_reverseAPIDeviceIndex, AMDemodSettings::m_reverseAPIPort, AMDemodSettings::m_rfBandwidth, m_settings, m_settingsMutex, AMDemodSettings::m_squelch, m_squelchLevel, AMDemodSettings::m_streamIndex, m_syncAMBuffIndex, AMDemodSettings::m_syncAMOperation, m_threadedChannelizer, AMDemodSettings::m_useReverseAPI, AMDemodSettings::m_volume, m_volumeAGC, CalcDb::powerFromdB(), DeviceAPI::removeChannelSink(), DeviceAPI::removeChannelSinkAPI(), SimpleAGC< AvgSize >::resizeNew(), and webapiReverseSendSettings().

Referenced by AMDemod(), and handleMessage().

437 {
438  qDebug() << "AMDemod::applySettings:"
439  << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
440  << " m_rfBandwidth: " << settings.m_rfBandwidth
441  << " m_volume: " << settings.m_volume
442  << " m_squelch: " << settings.m_squelch
443  << " m_audioMute: " << settings.m_audioMute
444  << " m_bandpassEnable: " << settings.m_bandpassEnable
445  << " m_audioDeviceName: " << settings.m_audioDeviceName
446  << " m_pll: " << settings.m_pll
447  << " m_syncAMOperation: " << (int) settings.m_syncAMOperation
448  << " m_streamIndex: " << settings.m_streamIndex
449  << " m_useReverseAPI: " << settings.m_useReverseAPI
450  << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
451  << " m_reverseAPIPort: " << settings.m_reverseAPIPort
452  << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
453  << " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
454  << " force: " << force;
455 
456  QList<QString> reverseAPIKeys;
457 
458  if((m_settings.m_rfBandwidth != settings.m_rfBandwidth) ||
459  (m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force)
460  {
461  m_settingsMutex.lock();
465  m_bandpass.create(301, m_audioSampleRate, 300.0, settings.m_rfBandwidth / 2.0f);
466  m_lowpass.create(301, m_audioSampleRate, settings.m_rfBandwidth / 2.0f);
467  DSBFilter->create_dsb_filter((2.0f * settings.m_rfBandwidth) / (float) m_audioSampleRate);
468  m_settingsMutex.unlock();
469 
470  if ((m_settings.m_rfBandwidth != settings.m_rfBandwidth) || force) {
471  reverseAPIKeys.append("rfBandwidth");
472  }
473  if ((m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force) {
474  reverseAPIKeys.append("bandpassEnable");
475  }
476  }
477 
478  if ((m_settings.m_squelch != settings.m_squelch) || force)
479  {
481  reverseAPIKeys.append("squelch");
482  }
483 
484  if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
485  {
487  int audioDeviceIndex = audioDeviceManager->getOutputDeviceIndex(settings.m_audioDeviceName);
488  //qDebug("AMDemod::applySettings: audioDeviceName: %s audioDeviceIndex: %d", qPrintable(settings.m_audioDeviceName), audioDeviceIndex);
489  audioDeviceManager->addAudioSink(&m_audioFifo, getInputMessageQueue(), audioDeviceIndex);
490  uint32_t audioSampleRate = audioDeviceManager->getOutputSampleRate(audioDeviceIndex);
491 
492  if (m_audioSampleRate != audioSampleRate) {
493  applyAudioSampleRate(audioSampleRate);
494  }
495 
496  reverseAPIKeys.append("audioDeviceName");
497  }
498 
499  if ((m_settings.m_pll != settings.m_pll) || force)
500  {
501  if (settings.m_pll)
502  {
503  m_volumeAGC.resizeNew(m_audioSampleRate/4, 0.003);
504  m_syncAMBuffIndex = 0;
505  }
506  else
507  {
508  m_volumeAGC.resizeNew(m_audioSampleRate/10, 0.003);
509  }
510 
511  reverseAPIKeys.append("pll");
512  reverseAPIKeys.append("syncAMOperation");
513  }
514 
515  if ((m_settings.m_syncAMOperation != settings.m_syncAMOperation) || force)
516  {
517  m_syncAMBuffIndex = 0;
518  reverseAPIKeys.append("pll");
519  reverseAPIKeys.append("syncAMOperation");
520  }
521 
522  if ((m_settings.m_inputFrequencyOffset != settings.m_inputFrequencyOffset) || force) {
523  reverseAPIKeys.append("inputFrequencyOffset");
524  }
525 
526  if ((m_settings.m_audioMute != settings.m_audioMute) || force) {
527  reverseAPIKeys.append("audioMute");
528  }
529 
530  if ((m_settings.m_volume != settings.m_volume) || force) {
531  reverseAPIKeys.append("volume");
532  }
533 
534  if (m_settings.m_streamIndex != settings.m_streamIndex)
535  {
536  if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
537  {
542  // apply stream sample rate to itself
544  }
545 
546  reverseAPIKeys.append("streamIndex");
547  }
548 
549  if (settings.m_useReverseAPI)
550  {
551  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
556  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
557  }
558 
559  m_settings = settings;
560 }
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: amdemod.cpp:410
int getOutputSampleRate(int outputDeviceIndex=-1)
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const AMDemodSettings &settings, bool force)
Definition: amdemod.cpp:748
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
void create(int nTaps, double sampleRate, double lowCutoff, double highCutoff)
Definition: bandpass.h:15
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
AMDemodSettings m_settings
Definition: amdemod.h:188
void create(int nTaps, double sampleRate, double cutoff)
Definition: lowpass.h:15
int getOutputDeviceIndex(const QString &deviceName) const
DeviceAPI * m_deviceAPI
Definition: amdemod.h:182
uint16_t m_reverseAPIChannelIndex
AudioFifo m_audioFifo
Definition: amdemod.h:221
fftfilt * DSBFilter
Definition: amdemod.h:213
unsigned int uint32_t
Definition: rtptypes_win.h:46
int m_streamIndex
MIMO channel. Not relevant when connected to SI (single Rx).
Real m_interpolatorDistance
Definition: amdemod.h:194
QMutex m_settingsMutex
Definition: amdemod.h:228
Lowpass< Real > m_lowpass
Definition: amdemod.h:210
uint16_t m_reverseAPIDeviceIndex
static DSPEngine * instance()
Definition: dspengine.cpp:51
int m_inputFrequencyOffset
Definition: amdemod.h:187
Interpolator m_interpolator
Definition: amdemod.h:193
SyncAMOperation m_syncAMOperation
QString m_audioDeviceName
uint32_t m_audioSampleRate
Definition: amdemod.h:189
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: amdemod.h:183
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
int m_inputSampleRate
Definition: amdemod.h:186
void applyAudioSampleRate(int sampleRate)
Definition: amdemod.cpp:377
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
QString m_reverseAPIAddress
void resizeNew(uint32_t newSize, Real initial, Real cutoff=0, Real clip=0)
Definition: agc.h:95
uint16_t m_reverseAPIPort
qint32 m_inputFrequencyOffset
Real m_squelchLevel
Definition: amdemod.h:197
virtual int getSourceSampleRate(int index) const =0
Sample rate exposed by the source at index.
Bandpass< Real > m_bandpass
Definition: amdemod.h:209
Real m_interpolatorDistanceRemain
Definition: amdemod.h:195
uint32_t m_syncAMBuffIndex
Definition: amdemod.h:216
DeviceSampleMIMO * getSampleMIMO()
Return pointer to the device sample MIMO or nullptr.
Definition: deviceapi.cpp:231
float Real
Definition: dsptypes.h:42
static double powerFromdB(double powerdB)
Definition: db.cpp:36
SimpleAGC< 4800 > m_volumeAGC
Definition: amdemod.h:208
void create_dsb_filter(float f2)
Definition: fftfilt.cpp:148
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements ChannelAPI.

Definition at line 567 of file amdemod.cpp.

References AMDemod::MsgConfigureAMDemod::create(), AMDemodSettings::deserialize(), BasebandSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and AMDemodSettings::resetToDefaults().

Referenced by getCenterFrequency().

568 {
569  if (m_settings.deserialize(data))
570  {
571  MsgConfigureAMDemod *msg = MsgConfigureAMDemod::create(m_settings, true);
573  return true;
574  }
575  else
576  {
578  MsgConfigureAMDemod *msg = MsgConfigureAMDemod::create(m_settings, true);
580  return false;
581  }
582 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
AMDemodSettings m_settings
Definition: amdemod.h:188
static MsgConfigureAMDemod * create(const AMDemodSettings &settings, bool force)
Definition: amdemod.h:58
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
bool deserialize(const QByteArray &data)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

virtual void AMDemod::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 99 of file amdemod.h.

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

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

◆ feed()

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

Implements BasebandSampleSink.

Definition at line 116 of file amdemod.cpp.

References Interpolator::decimate(), Interpolator::interpolate(), m_audioBuffer, m_audioBufferFill, m_audioFifo, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_nco, m_running, m_settingsMutex, NCO::nextIQ(), processOneSample(), and AudioFifo::write().

Referenced by destroy().

117 {
118  (void) firstOfBurst;
119  Complex ci;
120 
121  if (!m_running) {
122  return;
123  }
124 
125  m_settingsMutex.lock();
126 
127  for (SampleVector::const_iterator it = begin; it != end; ++it)
128  {
129  Complex c(it->real(), it->imag());
130  c *= m_nco.nextIQ();
131 
132  if (m_interpolatorDistance < 1.0f) // interpolate
133  {
135  {
136  processOneSample(ci);
138  }
139  }
140  else // decimate
141  {
143  {
144  processOneSample(ci);
146  }
147  }
148  }
149 
150  if (m_audioBufferFill > 0)
151  {
152  uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
153 
154  if (res != m_audioBufferFill)
155  {
156  qDebug("AMDemod::feed: %u/%u tail samples written", res, m_audioBufferFill);
157  }
158 
159  m_audioBufferFill = 0;
160  }
161 
162  m_settingsMutex.unlock();
163 }
Complex nextIQ()
Return next complex sample.
Definition: nco.cpp:61
bool decimate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:38
bool interpolate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:53
bool m_running
Definition: amdemod.h:190
AudioFifo m_audioFifo
Definition: amdemod.h:221
Real m_interpolatorDistance
Definition: amdemod.h:194
QMutex m_settingsMutex
Definition: amdemod.h:228
Interpolator m_interpolator
Definition: amdemod.h:193
void processOneSample(Complex &ci)
Definition: amdemod.cpp:165
AudioVector m_audioBuffer
Definition: amdemod.h:219
uint32_t m_audioBufferFill
Definition: amdemod.h:220
NCO m_nco
Definition: amdemod.h:192
Real m_interpolatorDistanceRemain
Definition: amdemod.h:195
std::complex< Real > Complex
Definition: dsptypes.h:43
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:

◆ getAudioSampleRate()

uint32_t AMDemod::getAudioSampleRate ( ) const
inline

Definition at line 137 of file amdemod.h.

References m_audioSampleRate.

Referenced by AMDemodGUI::applySettings(), and AMDemodGUI::tick().

137 { return m_audioSampleRate; }
uint32_t m_audioSampleRate
Definition: amdemod.h:189
+ Here is the caller graph for this function:

◆ getCenterFrequency()

virtual qint64 AMDemod::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 108 of file amdemod.h.

References deserialize(), AMDemodSettings::m_inputFrequencyOffset, AMDemod::MsgConfigureAMDemod::m_settings, and serialize().

AMDemodSettings m_settings
Definition: amdemod.h:188
qint32 m_inputFrequencyOffset
+ Here is the call graph for this function:

◆ getIdentifier()

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

Implements ChannelAPI.

Definition at line 106 of file amdemod.h.

106 { id = objectName(); }

◆ getMagSq()

double AMDemod::getMagSq ( ) const
inline

Definition at line 138 of file amdemod.h.

References m_magsq.

138 { return m_magsq; }
double m_magsq
Definition: amdemod.h:201

◆ getMagSqLevels()

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

Definition at line 143 of file amdemod.h.

References getNumberOfDeviceStreams(), AMDemod::MagSqLevelsStore::m_magsq, m_magsq, m_magsqCount, m_magSqLevelStore, AMDemod::MagSqLevelsStore::m_magsqPeak, m_magsqPeak, and m_magsqSum.

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

144  {
145  if (m_magsqCount > 0)
146  {
150  }
151 
154  nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
155 
156  m_magsqSum = 0.0f;
157  m_magsqPeak = 0.0f;
158  m_magsqCount = 0;
159  }
int m_magsqCount
Definition: amdemod.h:204
double m_magsqSum
Definition: amdemod.h:202
double m_magsq
Definition: amdemod.h:201
double m_magsqPeak
Definition: amdemod.h:203
MagSqLevelsStore m_magSqLevelStore
Definition: amdemod.h:205
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNbSinkStreams()

virtual int AMDemod::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 113 of file amdemod.h.

113 { return 1; }

◆ getNbSourceStreams()

virtual int AMDemod::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 114 of file amdemod.h.

114 { return 0; }

◆ getNumberOfDeviceStreams()

uint32_t AMDemod::getNumberOfDeviceStreams ( ) const

Definition at line 111 of file amdemod.cpp.

References DeviceAPI::getNbSourceStreams(), and m_deviceAPI.

Referenced by getMagSqLevels(), and AMDemodGUI::onMenuDialogCalled().

112 {
114 }
DeviceAPI * m_deviceAPI
Definition: amdemod.h:182
uint32_t getNbSourceStreams() const
Definition: deviceapi.h:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPllFrequency()

Real AMDemod::getPllFrequency ( ) const
inline

Definition at line 141 of file amdemod.h.

References PhaseLockComplex::getFreq(), and m_pll.

Referenced by AMDemodGUI::tick().

141 { return m_pll.getFreq(); }
float getFreq() const
PhaseLockComplex m_pll
Definition: amdemod.h:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPllLocked()

bool AMDemod::getPllLocked ( ) const
inline

Definition at line 140 of file amdemod.h.

References PhaseLockComplex::locked(), AMDemodSettings::m_pll, m_pll, and AMDemod::MsgConfigureAMDemod::m_settings.

Referenced by AMDemodGUI::tick().

140 { return m_settings.m_pll && m_pll.locked(); }
AMDemodSettings m_settings
Definition: amdemod.h:188
PhaseLockComplex m_pll
Definition: amdemod.h:212
bool locked() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSquelchOpen()

bool AMDemod::getSquelchOpen ( ) const
inline

Definition at line 139 of file amdemod.h.

References m_squelchOpen.

Referenced by AMDemodGUI::tick().

139 { return m_squelchOpen; }
bool m_squelchOpen
Definition: amdemod.h:199
+ Here is the caller graph for this function:

◆ getStreamCenterFrequency()

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

Implements ChannelAPI.

Definition at line 116 of file amdemod.h.

References AMDemodSettings::m_inputFrequencyOffset, AMDemod::MsgConfigureAMDemod::m_settings, webapiReportGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

117  {
118  (void) streamIndex;
119  (void) sinkElseSource;
121  }
AMDemodSettings m_settings
Definition: amdemod.h:188
qint32 m_inputFrequencyOffset
+ Here is the call graph for this function:

◆ getTitle()

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

Implements ChannelAPI.

Definition at line 107 of file amdemod.h.

References AMDemod::MsgConfigureAMDemod::m_settings, and AMDemodSettings::m_title.

107 { title = m_settings.m_title; }
AMDemodSettings m_settings
Definition: amdemod.h:188

◆ handleMessage()

bool AMDemod::handleMessage ( const Message cmd)
virtual

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

Implements BasebandSampleSink.

Definition at line 310 of file amdemod.cpp.

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

Referenced by destroy().

311 {
313  {
315 
316  qDebug() << "AMDemod::handleMessage: MsgChannelizerNotification:"
317  << " inputSampleRate: " << notif.getSampleRate()
318  << " inputFrequencyOffset: " << notif.getFrequencyOffset();
319 
321 
322  return true;
323  }
324  else if (MsgConfigureChannelizer::match(cmd))
325  {
326  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
327 
328  qDebug() << "AMDemod::handleMessage: MsgConfigureChannelizer:"
329  << " sampleRate: " << cfg.getSampleRate()
330  << " inputFrequencyOffset: " << cfg.getCenterFrequency();
331 
333  cfg.getSampleRate(),
334  cfg.getCenterFrequency());
335 
336  return true;
337  }
338  else if (MsgConfigureAMDemod::match(cmd))
339  {
340  MsgConfigureAMDemod& cfg = (MsgConfigureAMDemod&) cmd;
341  qDebug() << "AMDemod::handleMessage: MsgConfigureAMDemod";
342  applySettings(cfg.getSettings(), cfg.getForce());
343 
344  return true;
345  }
347  {
349  const QThread *thread = cfg.getThread();
350  qDebug("AMDemod::handleMessage: BasebandSampleSink::MsgThreadedSink: %p", thread);
351  return true;
352  }
353  else if (DSPSignalNotification::match(cmd))
354  {
355  return true;
356  }
357  else if (DSPConfigureAudio::match(cmd))
358  {
359  DSPConfigureAudio& cfg = (DSPConfigureAudio&) cmd;
360  uint32_t sampleRate = cfg.getSampleRate();
361 
362  qDebug() << "AMDemod::handleMessage: DSPConfigureAudio:"
363  << " sampleRate: " << sampleRate;
364 
365  if (sampleRate != m_audioSampleRate) {
366  applyAudioSampleRate(sampleRate);
367  }
368 
369  return true;
370  }
371  else
372  {
373  return false;
374  }
375 }
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: amdemod.cpp:410
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
uint32_t m_audioSampleRate
Definition: amdemod.h:189
DownChannelizer * m_channelizer
Definition: amdemod.h:184
void applySettings(const AMDemodSettings &settings, bool force=false)
Definition: amdemod.cpp:436
void applyAudioSampleRate(int sampleRate)
Definition: amdemod.cpp:377
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void AMDemod::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 816 of file amdemod.cpp.

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

817 {
818  QNetworkReply::NetworkError replyError = reply->error();
819 
820  if (replyError)
821  {
822  qWarning() << "AMDemod::networkManagerFinished:"
823  << " error(" << (int) replyError
824  << "): " << replyError
825  << ": " << reply->errorString();
826  return;
827  }
828 
829  QString answer = reply->readAll();
830  answer.chop(1); // remove last \n
831  qDebug("AMDemod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
832 }
+ Here is the caller graph for this function:

◆ processOneSample()

void AMDemod::processOneSample ( Complex ci)
private

Definition at line 165 of file amdemod.cpp.

References MovingAverageUtil< T, Total, N >::asDouble(), AudioFifo::clear(), DSBFilter, PhaseLockComplex::feed(), SimpleAGC< AvgSize >::feed(), MagAGC::feedAndGetValue(), Lowpass< Type >::filter(), Bandpass< Type >::filter(), PhaseLockComplex::getImag(), PhaseLockComplex::getReal(), SimpleAGC< AvgSize >::getValue(), i, m_audioBuffer, m_audioBufferFill, m_audioFifo, AMDemodSettings::m_audioMute, m_audioSampleRate, m_bandpass, AMDemodSettings::m_bandpassEnable, m_lowpass, m_magsq, m_magsqCount, m_magsqPeak, m_magsqSum, m_movingAverage, AMDemodSettings::m_pll, m_pll, m_pllFilt, m_settings, m_squelchCount, m_squelchDelayLine, m_squelchLevel, m_squelchOpen, m_syncAMAGC, m_syncAMBuff, m_syncAMBuffIndex, AMDemodSettings::m_syncAMOperation, AMDemodSettings::m_volume, m_volumeAGC, DoubleBufferFIFO< T >::readBack(), fftfilt::runDSB(), fftfilt::runSSB(), SDR_RX_SCALEF, StepFunctions::smootherstep(), sqrt(), SSBFilter, AMDemodSettings::SyncAMDSB, AMDemodSettings::SyncAMUSB, AudioFifo::write(), and DoubleBufferFIFO< T >::write().

Referenced by feed().

166 {
167  Real re = ci.real() / SDR_RX_SCALEF;
168  Real im = ci.imag() / SDR_RX_SCALEF;
169  Real magsq = re*re + im*im;
170  m_movingAverage(magsq);
172  m_magsqSum += magsq;
173 
174  if (magsq > m_magsqPeak)
175  {
176  m_magsqPeak = magsq;
177  }
178 
179  m_magsqCount++;
180 
181  m_squelchDelayLine.write(magsq);
182 
183  if (m_magsq < m_squelchLevel)
184  {
185  if (m_squelchCount > 0) {
186  m_squelchCount--;
187  }
188  }
189  else
190  {
191  if (m_squelchCount < m_audioSampleRate / 10) {
192  m_squelchCount++;
193  }
194  }
195 
196  qint16 sample;
197 
199 
201  {
202  Real demod;
203 
204  if (m_settings.m_pll)
205  {
206  std::complex<float> s(re, im);
207  s = m_pllFilt.filter(s);
208  m_pll.feed(s.real(), s.imag());
209  float yr = re * m_pll.getImag() - im * m_pll.getReal();
210  float yi = re * m_pll.getReal() + im * m_pll.getImag();
211 
212  fftfilt::cmplx *sideband;
213  std::complex<float> cs(yr, yi);
214  int n_out;
215 
217  n_out = DSBFilter->runDSB(cs, &sideband, false);
218  } else {
219  n_out = SSBFilter->runSSB(cs, &sideband, m_settings.m_syncAMOperation == AMDemodSettings::SyncAMUSB, false);
220  }
221 
222  for (int i = 0; i < n_out; i++)
223  {
224  float agcVal = m_syncAMAGC.feedAndGetValue(sideband[i]);
225  fftfilt::cmplx z = sideband[i] * agcVal; // * m_syncAMAGC.getStepValue();
226 
228  m_syncAMBuff[i] = (z.real() + z.imag());
230  m_syncAMBuff[i] = (z.real() + z.imag());
231  } else {
232  m_syncAMBuff[i] = (z.real() + z.imag());
233  }
234 
235 // if (m_settings.m_syncAMOperation == AMDemodSettings::SyncAMDSB) {
236 // m_syncAMBuff[i] = (sideband[i].real() + sideband[i].imag())/2.0f;
237 // } else if (m_settings.m_syncAMOperation == AMDemodSettings::SyncAMUSB) {
238 // m_syncAMBuff[i] = (sideband[i].real() + sideband[i].imag());
239 // } else {
240 // m_syncAMBuff[i] = (sideband[i].real() + sideband[i].imag());
241 // }
242 
243  m_syncAMBuffIndex = 0;
244  }
245 
247  demod = m_syncAMBuff[m_syncAMBuffIndex++]*4.0f; // mos pifometrico
248 // demod = m_syncAMBuff[m_syncAMBuffIndex++]*(SDR_RX_SCALEF/602.0f);
249 // m_volumeAGC.feed(demod);
250 // demod /= (10.0*m_volumeAGC.getValue());
251  }
252  else
253  {
255  m_volumeAGC.feed(demod);
256  demod = (demod - m_volumeAGC.getValue()) / m_volumeAGC.getValue();
257  }
258 
260  {
261  demod = m_bandpass.filter(demod);
262  demod /= 301.0f;
263  }
264  else
265  {
266  demod = m_lowpass.filter(demod);
267  }
268 
269  Real attack = (m_squelchCount - 0.05f * m_audioSampleRate) / (0.05f * m_audioSampleRate);
270  sample = demod * StepFunctions::smootherstep(attack) * (m_audioSampleRate/24) * m_settings.m_volume;
271  }
272  else
273  {
274  sample = 0;
275  }
276 
277  m_audioBuffer[m_audioBufferFill].l = sample;
278  m_audioBuffer[m_audioBufferFill].r = sample;
280 
281  if (m_audioBufferFill >= m_audioBuffer.size())
282  {
283  uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
284 
285  if (res != m_audioBufferFill)
286  {
287  qDebug("AMDemod::processOneSample: %u/%u audio samples written", res, m_audioBufferFill);
288  m_audioFifo.clear();
289  }
290 
291  m_audioBufferFill = 0;
292  }
293 }
Real m_syncAMBuff[2 *1024]
Definition: amdemod.h:215
int m_magsqCount
Definition: amdemod.h:204
MagAGC m_syncAMAGC
Definition: amdemod.h:217
double m_magsqSum
Definition: amdemod.h:202
AMDemodSettings m_settings
Definition: amdemod.h:188
void clear()
Definition: audiofifo.cpp:156
double m_magsq
Definition: amdemod.h:201
Type filter(Type sample)
Definition: bandpass.h:77
uint32_t m_squelchCount
Definition: amdemod.h:198
static float smootherstep(float x)
Definition: stepfunctions.h:24
fftfilt * SSBFilter
Definition: amdemod.h:214
AudioFifo m_audioFifo
Definition: amdemod.h:221
Real getValue()
Definition: agc.h:107
fftfilt * DSBFilter
Definition: amdemod.h:213
double feedAndGetValue(const Complex &ci)
Definition: agc.cpp:108
std::complex< float > cmplx
Definition: fftfilt.h:21
void write(const T &element)
#define SDR_RX_SCALEF
Definition: dsptypes.h:33
MovingAverageUtil< Real, double, 16 > m_movingAverage
Definition: amdemod.h:207
void feed(Real value)
Definition: agc.h:116
Lowpass< Real > m_lowpass
Definition: amdemod.h:210
int32_t i
Definition: decimators.h:244
SyncAMOperation m_syncAMOperation
uint32_t m_audioSampleRate
Definition: amdemod.h:189
DoubleBufferFIFO< Real > m_squelchDelayLine
Definition: amdemod.h:200
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2283
double m_magsqPeak
Definition: amdemod.h:203
Lowpass< std::complex< float > > m_pllFilt
Definition: amdemod.h:211
T & readBack(int delay)
AudioVector m_audioBuffer
Definition: amdemod.h:219
Type filter(Type sample)
Definition: lowpass.h:55
uint32_t m_audioBufferFill
Definition: amdemod.h:220
PhaseLockComplex m_pll
Definition: amdemod.h:212
int runSSB(const cmplx &in, cmplx **out, bool usb, bool getDC=true)
Definition: fftfilt.cpp:284
Real m_squelchLevel
Definition: amdemod.h:197
Bandpass< Real > m_bandpass
Definition: amdemod.h:209
float getImag() const
uint32_t m_syncAMBuffIndex
Definition: amdemod.h:216
double asDouble() const
Definition: movingaverage.h:57
int runDSB(const cmplx &in, cmplx **out, bool getDC=true)
Definition: fftfilt.cpp:327
float Real
Definition: dsptypes.h:42
void feed(float re, float im)
bool m_squelchOpen
Definition: amdemod.h:199
float getReal() const
uint32_t write(const quint8 *data, uint32_t numSamples)
Definition: audiofifo.cpp:66
SimpleAGC< 4800 > m_volumeAGC
Definition: amdemod.h:208
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray AMDemod::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 562 of file amdemod.cpp.

References m_settings, and AMDemodSettings::serialize().

Referenced by getCenterFrequency().

563 {
564  return m_settings.serialize();
565 }
AMDemodSettings m_settings
Definition: amdemod.h:188
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

void AMDemod::start ( )
virtual

Implements BasebandSampleSink.

Definition at line 295 of file amdemod.cpp.

References applyChannelSettings(), AudioFifo::clear(), m_audioFifo, m_inputFrequencyOffset, m_inputSampleRate, m_running, and m_squelchCount.

Referenced by destroy().

296 {
297  qDebug("AMDemod::start");
298  m_squelchCount = 0;
299  m_audioFifo.clear();
301  m_running = true;
302 }
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: amdemod.cpp:410
void clear()
Definition: audiofifo.cpp:156
uint32_t m_squelchCount
Definition: amdemod.h:198
bool m_running
Definition: amdemod.h:190
AudioFifo m_audioFifo
Definition: amdemod.h:221
int m_inputFrequencyOffset
Definition: amdemod.h:187
int m_inputSampleRate
Definition: amdemod.h:186
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void AMDemod::stop ( )
virtual

Implements BasebandSampleSink.

Definition at line 304 of file amdemod.cpp.

References m_running.

Referenced by destroy().

305 {
306  qDebug("AMDemod::stop");
307  m_running = false;
308 }
bool m_running
Definition: amdemod.h:190
+ Here is the caller graph for this function:

◆ webapiFormatChannelReport()

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

Definition at line 736 of file amdemod.cpp.

References CalcDb::dbPower(), SWGSDRangel::SWGChannelReport::getAmDemodReport(), getMagSqLevels(), m_audioSampleRate, m_inputSampleRate, m_squelchOpen, SWGSDRangel::SWGAMDemodReport::setAudioSampleRate(), SWGSDRangel::SWGAMDemodReport::setChannelPowerDb(), SWGSDRangel::SWGAMDemodReport::setChannelSampleRate(), and SWGSDRangel::SWGAMDemodReport::setSquelch().

Referenced by webapiReportGet().

737 {
738  double magsqAvg, magsqPeak;
739  int nbMagsqSamples;
740  getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
741 
742  response.getAmDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg));
743  response.getAmDemodReport()->setSquelch(m_squelchOpen ? 1 : 0);
746 }
static double dbPower(double magsq, double floor=1e-12)
Definition: db.cpp:22
void getMagSqLevels(double &avg, double &peak, int &nbSamples)
Definition: amdemod.h:143
SWGAMDemodReport * getAmDemodReport()
void setChannelPowerDb(float channel_power_db)
uint32_t m_audioSampleRate
Definition: amdemod.h:189
int m_inputSampleRate
Definition: amdemod.h:186
void setChannelSampleRate(qint32 channel_sample_rate)
void setAudioSampleRate(qint32 audio_sample_rate)
bool m_squelchOpen
Definition: amdemod.h:199
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatChannelSettings()

void AMDemod::webapiFormatChannelSettings ( SWGSDRangel::SWGChannelSettings response,
const AMDemodSettings settings 
)
private

Definition at line 698 of file amdemod.cpp.

References SWGSDRangel::SWGChannelSettings::getAmDemodSettings(), SWGSDRangel::SWGAMDemodSettings::getAudioDeviceName(), SWGSDRangel::SWGAMDemodSettings::getReverseApiAddress(), SWGSDRangel::SWGAMDemodSettings::getTitle(), AMDemodSettings::m_audioDeviceName, AMDemodSettings::m_audioMute, AMDemodSettings::m_bandpassEnable, AMDemodSettings::m_inputFrequencyOffset, AMDemodSettings::m_pll, AMDemodSettings::m_reverseAPIAddress, AMDemodSettings::m_reverseAPIChannelIndex, AMDemodSettings::m_reverseAPIDeviceIndex, AMDemodSettings::m_reverseAPIPort, AMDemodSettings::m_rfBandwidth, AMDemodSettings::m_rgbColor, m_settings, AMDemodSettings::m_squelch, AMDemodSettings::m_streamIndex, AMDemodSettings::m_syncAMOperation, AMDemodSettings::m_title, AMDemodSettings::m_useReverseAPI, AMDemodSettings::m_volume, SWGSDRangel::SWGAMDemodSettings::setAudioDeviceName(), SWGSDRangel::SWGAMDemodSettings::setAudioMute(), SWGSDRangel::SWGAMDemodSettings::setBandpassEnable(), SWGSDRangel::SWGAMDemodSettings::setInputFrequencyOffset(), SWGSDRangel::SWGAMDemodSettings::setPll(), SWGSDRangel::SWGAMDemodSettings::setReverseApiAddress(), SWGSDRangel::SWGAMDemodSettings::setReverseApiChannelIndex(), SWGSDRangel::SWGAMDemodSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGAMDemodSettings::setReverseApiPort(), SWGSDRangel::SWGAMDemodSettings::setRfBandwidth(), SWGSDRangel::SWGAMDemodSettings::setRgbColor(), SWGSDRangel::SWGAMDemodSettings::setSquelch(), SWGSDRangel::SWGAMDemodSettings::setStreamIndex(), SWGSDRangel::SWGAMDemodSettings::setSyncAmOperation(), SWGSDRangel::SWGAMDemodSettings::setTitle(), SWGSDRangel::SWGAMDemodSettings::setUseReverseApi(), and SWGSDRangel::SWGAMDemodSettings::setVolume().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

699 {
700  response.getAmDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
702  response.getAmDemodSettings()->setRfBandwidth(settings.m_rfBandwidth);
703  response.getAmDemodSettings()->setRgbColor(settings.m_rgbColor);
704  response.getAmDemodSettings()->setSquelch(settings.m_squelch);
705  response.getAmDemodSettings()->setVolume(settings.m_volume);
706  response.getAmDemodSettings()->setBandpassEnable(settings.m_bandpassEnable ? 1 : 0);
707 
708  if (response.getAmDemodSettings()->getTitle()) {
709  *response.getAmDemodSettings()->getTitle() = settings.m_title;
710  } else {
711  response.getAmDemodSettings()->setTitle(new QString(settings.m_title));
712  }
713 
714  if (response.getAmDemodSettings()->getAudioDeviceName()) {
715  *response.getAmDemodSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
716  } else {
717  response.getAmDemodSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
718  }
719 
720  response.getAmDemodSettings()->setPll(settings.m_pll ? 1 : 0);
723  response.getAmDemodSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
724 
725  if (response.getAmDemodSettings()->getReverseApiAddress()) {
727  } else {
728  response.getAmDemodSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
729  }
730 
734 }
void setAudioDeviceName(QString *audio_device_name)
AMDemodSettings m_settings
Definition: amdemod.h:188
void setSyncAmOperation(qint32 sync_am_operation)
uint16_t m_reverseAPIChannelIndex
void setReverseApiAddress(QString *reverse_api_address)
int m_streamIndex
MIMO channel. Not relevant when connected to SI (single Rx).
uint16_t m_reverseAPIDeviceIndex
SWGAMDemodSettings * getAmDemodSettings()
void setUseReverseApi(qint32 use_reverse_api)
void setBandpassEnable(qint32 bandpass_enable)
void setRfBandwidth(float rf_bandwidth)
SyncAMOperation m_syncAMOperation
QString m_audioDeviceName
void setInputFrequencyOffset(qint64 input_frequency_offset)
QString m_reverseAPIAddress
uint16_t m_reverseAPIPort
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
qint32 m_inputFrequencyOffset
void setAudioMute(qint32 audio_mute)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiPort(qint32 reverse_api_port)
void setStreamIndex(qint32 stream_index)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from ChannelAPI.

Definition at line 687 of file amdemod.cpp.

References SWGSDRangel::SWGChannelReport::getAmDemodReport(), SWGSDRangel::SWGAMDemodReport::init(), SWGSDRangel::SWGChannelReport::setAmDemodReport(), and webapiFormatChannelReport().

Referenced by getStreamCenterFrequency().

690 {
691  (void) errorMessage;
693  response.getAmDemodReport()->init();
694  webapiFormatChannelReport(response);
695  return 200;
696 }
SWGAMDemodReport * getAmDemodReport()
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
Definition: amdemod.cpp:736
void setAmDemodReport(SWGAMDemodReport *am_demod_report)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 748 of file amdemod.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), SWGSDRangel::SWGChannelSettings::getAmDemodSettings(), ChannelAPI::getDeviceSetIndex(), ChannelAPI::getIndexInDeviceSet(), AMDemodSettings::m_audioDeviceName, AMDemodSettings::m_audioMute, AMDemodSettings::m_bandpassEnable, AMDemodSettings::m_inputFrequencyOffset, m_networkManager, m_networkRequest, AMDemodSettings::m_pll, AMDemodSettings::m_reverseAPIAddress, AMDemodSettings::m_reverseAPIChannelIndex, AMDemodSettings::m_reverseAPIDeviceIndex, AMDemodSettings::m_reverseAPIPort, AMDemodSettings::m_rfBandwidth, AMDemodSettings::m_rgbColor, AMDemodSettings::m_squelch, AMDemodSettings::m_streamIndex, AMDemodSettings::m_syncAMOperation, AMDemodSettings::m_title, AMDemodSettings::m_volume, SWGSDRangel::SWGChannelSettings::setAmDemodSettings(), SWGSDRangel::SWGAMDemodSettings::setAudioDeviceName(), SWGSDRangel::SWGAMDemodSettings::setAudioMute(), SWGSDRangel::SWGAMDemodSettings::setBandpassEnable(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGAMDemodSettings::setInputFrequencyOffset(), SWGSDRangel::SWGChannelSettings::setOriginatorChannelIndex(), SWGSDRangel::SWGChannelSettings::setOriginatorDeviceSetIndex(), SWGSDRangel::SWGAMDemodSettings::setPll(), SWGSDRangel::SWGAMDemodSettings::setRfBandwidth(), SWGSDRangel::SWGAMDemodSettings::setRgbColor(), SWGSDRangel::SWGAMDemodSettings::setSquelch(), SWGSDRangel::SWGAMDemodSettings::setStreamIndex(), SWGSDRangel::SWGAMDemodSettings::setSyncAmOperation(), SWGSDRangel::SWGAMDemodSettings::setTitle(), and SWGSDRangel::SWGAMDemodSettings::setVolume().

Referenced by applySettings().

749 {
751  swgChannelSettings->setDirection(0); // Single sink (Rx)
752  swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
753  swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
754  swgChannelSettings->setChannelType(new QString("AMDemod"));
755  swgChannelSettings->setAmDemodSettings(new SWGSDRangel::SWGAMDemodSettings());
756  SWGSDRangel::SWGAMDemodSettings *swgAMDemodSettings = swgChannelSettings->getAmDemodSettings();
757 
758  // transfer data that has been modified. When force is on transfer all data except reverse API data
759 
760  if (channelSettingsKeys.contains("audioMute") || force) {
761  swgAMDemodSettings->setAudioMute(settings.m_audioMute ? 1 : 0);
762  }
763  if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
764  swgAMDemodSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
765  }
766  if (channelSettingsKeys.contains("rfBandwidth") || force) {
767  swgAMDemodSettings->setRfBandwidth(settings.m_rfBandwidth);
768  }
769  if (channelSettingsKeys.contains("rgbColor") || force) {
770  swgAMDemodSettings->setRgbColor(settings.m_rgbColor);
771  }
772  if (channelSettingsKeys.contains("squelch") || force) {
773  swgAMDemodSettings->setSquelch(settings.m_squelch);
774  }
775  if (channelSettingsKeys.contains("title") || force) {
776  swgAMDemodSettings->setTitle(new QString(settings.m_title));
777  }
778  if (channelSettingsKeys.contains("volume") || force) {
779  swgAMDemodSettings->setVolume(settings.m_volume);
780  }
781  if (channelSettingsKeys.contains("bandpassEnable") || force) {
782  swgAMDemodSettings->setBandpassEnable(settings.m_bandpassEnable ? 1 : 0);
783  }
784  if (channelSettingsKeys.contains("audioDeviceName") || force) {
785  swgAMDemodSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
786  }
787  if (channelSettingsKeys.contains("pll") || force) {
788  swgAMDemodSettings->setPll(settings.m_pll);
789  }
790  if (channelSettingsKeys.contains("syncAMOperation") || force) {
791  swgAMDemodSettings->setSyncAmOperation((int) settings.m_syncAMOperation);
792  }
793  if (channelSettingsKeys.contains("streamIndex") || force) {
794  swgAMDemodSettings->setStreamIndex(settings.m_streamIndex);
795  }
796 
797  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
798  .arg(settings.m_reverseAPIAddress)
799  .arg(settings.m_reverseAPIPort)
800  .arg(settings.m_reverseAPIDeviceIndex)
801  .arg(settings.m_reverseAPIChannelIndex);
802  m_networkRequest.setUrl(QUrl(channelSettingsURL));
803  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
804 
805  QBuffer *buffer=new QBuffer();
806  buffer->open((QBuffer::ReadWrite));
807  buffer->write(swgChannelSettings->asJson().toUtf8());
808  buffer->seek(0);
809 
810  // Always use PATCH to avoid passing reverse API settings
811  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
812 
813  delete swgChannelSettings;
814 }
void setOriginatorChannelIndex(qint32 originator_channel_index)
QNetworkAccessManager * m_networkManager
Definition: amdemod.h:225
void setAudioDeviceName(QString *audio_device_name)
int getDeviceSetIndex() const
Definition: channelapi.h:89
void setSyncAmOperation(qint32 sync_am_operation)
uint16_t m_reverseAPIChannelIndex
void setChannelType(QString *channel_type)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
int m_streamIndex
MIMO channel. Not relevant when connected to SI (single Rx).
uint16_t m_reverseAPIDeviceIndex
SWGAMDemodSettings * getAmDemodSettings()
void setAmDemodSettings(SWGAMDemodSettings *am_demod_settings)
void setBandpassEnable(qint32 bandpass_enable)
void setRfBandwidth(float rf_bandwidth)
SyncAMOperation m_syncAMOperation
QString m_audioDeviceName
void setInputFrequencyOffset(qint64 input_frequency_offset)
virtual QString asJson() override
QString m_reverseAPIAddress
uint16_t m_reverseAPIPort
qint32 m_inputFrequencyOffset
void setAudioMute(qint32 audio_mute)
QNetworkRequest m_networkRequest
Definition: amdemod.h:226
int getIndexInDeviceSet() const
Definition: channelapi.h:87
void setStreamIndex(qint32 stream_index)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from ChannelAPI.

Definition at line 584 of file amdemod.cpp.

References SWGSDRangel::SWGChannelSettings::getAmDemodSettings(), SWGSDRangel::SWGAMDemodSettings::init(), m_settings, SWGSDRangel::SWGChannelSettings::setAmDemodSettings(), and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

587 {
588  (void) errorMessage;
590  response.getAmDemodSettings()->init();
592  return 200;
593 }
AMDemodSettings m_settings
Definition: amdemod.h:188
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const AMDemodSettings &settings)
Definition: amdemod.cpp:698
SWGAMDemodSettings * getAmDemodSettings()
void setAmDemodSettings(SWGAMDemodSettings *am_demod_settings)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from ChannelAPI.

Definition at line 595 of file amdemod.cpp.

References AMDemod::MsgConfigureAMDemod::create(), AMDemod::MsgConfigureChannelizer::create(), SWGSDRangel::SWGChannelSettings::getAmDemodSettings(), SWGSDRangel::SWGAMDemodSettings::getAudioDeviceName(), SWGSDRangel::SWGAMDemodSettings::getAudioMute(), SWGSDRangel::SWGAMDemodSettings::getBandpassEnable(), SWGSDRangel::SWGAMDemodSettings::getInputFrequencyOffset(), SWGSDRangel::SWGAMDemodSettings::getPll(), SWGSDRangel::SWGAMDemodSettings::getReverseApiAddress(), SWGSDRangel::SWGAMDemodSettings::getReverseApiChannelIndex(), SWGSDRangel::SWGAMDemodSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGAMDemodSettings::getReverseApiPort(), SWGSDRangel::SWGAMDemodSettings::getRfBandwidth(), SWGSDRangel::SWGAMDemodSettings::getRgbColor(), SWGSDRangel::SWGAMDemodSettings::getSquelch(), SWGSDRangel::SWGAMDemodSettings::getStreamIndex(), SWGSDRangel::SWGAMDemodSettings::getSyncAmOperation(), SWGSDRangel::SWGAMDemodSettings::getTitle(), SWGSDRangel::SWGAMDemodSettings::getUseReverseApi(), SWGSDRangel::SWGAMDemodSettings::getVolume(), AMDemodSettings::m_audioDeviceName, AMDemodSettings::m_audioMute, m_audioSampleRate, AMDemodSettings::m_bandpassEnable, BasebandSampleSink::m_guiMessageQueue, AMDemodSettings::m_inputFrequencyOffset, BasebandSampleSink::m_inputMessageQueue, AMDemodSettings::m_pll, AMDemodSettings::m_reverseAPIAddress, AMDemodSettings::m_reverseAPIChannelIndex, AMDemodSettings::m_reverseAPIDeviceIndex, AMDemodSettings::m_reverseAPIPort, AMDemodSettings::m_rfBandwidth, AMDemodSettings::m_rgbColor, m_settings, AMDemodSettings::m_squelch, AMDemodSettings::m_streamIndex, AMDemodSettings::m_syncAMOperation, AMDemodSettings::m_title, AMDemodSettings::m_useReverseAPI, AMDemodSettings::m_volume, MessageQueue::push(), AMDemodSettings::SyncAMDSB, AMDemodSettings::SyncAMLSB, and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

600 {
601  (void) errorMessage;
602  AMDemodSettings settings = m_settings;
603  bool frequencyOffsetChanged = false;
604 
605  if (channelSettingsKeys.contains("audioMute")) {
606  settings.m_audioMute = response.getAmDemodSettings()->getAudioMute() != 0;
607  }
608  if (channelSettingsKeys.contains("inputFrequencyOffset"))
609  {
611  frequencyOffsetChanged = true;
612  }
613  if (channelSettingsKeys.contains("rfBandwidth")) {
614  settings.m_rfBandwidth = response.getAmDemodSettings()->getRfBandwidth();
615  }
616  if (channelSettingsKeys.contains("rgbColor")) {
617  settings.m_rgbColor = response.getAmDemodSettings()->getRgbColor();
618  }
619  if (channelSettingsKeys.contains("squelch")) {
620  settings.m_squelch = response.getAmDemodSettings()->getSquelch();
621  }
622  if (channelSettingsKeys.contains("title")) {
623  settings.m_title = *response.getAmDemodSettings()->getTitle();
624  }
625  if (channelSettingsKeys.contains("volume")) {
626  settings.m_volume = response.getAmDemodSettings()->getVolume();
627  }
628  if (channelSettingsKeys.contains("bandpassEnable")) {
629  settings.m_bandpassEnable = response.getAmDemodSettings()->getBandpassEnable() != 0;
630  }
631  if (channelSettingsKeys.contains("audioDeviceName")) {
632  settings.m_audioDeviceName = *response.getAmDemodSettings()->getAudioDeviceName();
633  }
634 
635  if (channelSettingsKeys.contains("pll")) {
636  settings.m_pll = response.getAmDemodSettings()->getPll();
637  }
638 
639  if (channelSettingsKeys.contains("syncAMOperation")) {
640  qint32 syncAMOperationCode = response.getAmDemodSettings()->getSyncAmOperation();
641  settings.m_syncAMOperation = syncAMOperationCode < 0 ?
642  AMDemodSettings::SyncAMDSB : syncAMOperationCode > 2 ?
644  }
645 
646  if (channelSettingsKeys.contains("streamIndex")) {
647  settings.m_streamIndex = response.getAmDemodSettings()->getStreamIndex();
648  }
649  if (channelSettingsKeys.contains("useReverseAPI")) {
650  settings.m_useReverseAPI = response.getAmDemodSettings()->getUseReverseApi() != 0;
651  }
652  if (channelSettingsKeys.contains("reverseAPIAddress")) {
654  }
655  if (channelSettingsKeys.contains("reverseAPIPort")) {
656  settings.m_reverseAPIPort = response.getAmDemodSettings()->getReverseApiPort();
657  }
658  if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
660  }
661  if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
663  }
664 
665  if (frequencyOffsetChanged)
666  {
667  MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
669  m_inputMessageQueue.push(channelConfigMsg);
670  }
671 
672  MsgConfigureAMDemod *msg = MsgConfigureAMDemod::create(settings, force);
674 
675  qDebug("AMDemod::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
676  if (m_guiMessageQueue) // forward to GUI if any
677  {
678  MsgConfigureAMDemod *msgToGUI = MsgConfigureAMDemod::create(settings, force);
679  m_guiMessageQueue->push(msgToGUI);
680  }
681 
682  webapiFormatChannelSettings(response, settings);
683 
684  return 200;
685 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
AMDemodSettings m_settings
Definition: amdemod.h:188
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const AMDemodSettings &settings)
Definition: amdemod.cpp:698
static MsgConfigureAMDemod * create(const AMDemodSettings &settings, bool force)
Definition: amdemod.h:58
uint16_t m_reverseAPIChannelIndex
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
int m_streamIndex
MIMO channel. Not relevant when connected to SI (single Rx).
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
uint16_t m_reverseAPIDeviceIndex
SWGAMDemodSettings * getAmDemodSettings()
SyncAMOperation m_syncAMOperation
QString m_audioDeviceName
uint32_t m_audioSampleRate
Definition: amdemod.h:189
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: amdemod.h:81
QString m_reverseAPIAddress
uint16_t m_reverseAPIPort
qint32 m_inputFrequencyOffset
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ DSBFilter

fftfilt* AMDemod::DSBFilter
private

Definition at line 213 of file amdemod.h.

Referenced by AMDemod(), applyAudioSampleRate(), applySettings(), processOneSample(), and ~AMDemod().

◆ m_audioBuffer

AudioVector AMDemod::m_audioBuffer
private

Definition at line 219 of file amdemod.h.

Referenced by AMDemod(), feed(), and processOneSample().

◆ m_audioBufferFill

uint32_t AMDemod::m_audioBufferFill
private

Definition at line 220 of file amdemod.h.

Referenced by AMDemod(), feed(), and processOneSample().

◆ m_audioFifo

AudioFifo AMDemod::m_audioFifo
private

◆ m_audioSampleRate

uint32_t AMDemod::m_audioSampleRate
private

◆ m_bandpass

Bandpass<Real> AMDemod::m_bandpass
private

Definition at line 209 of file amdemod.h.

Referenced by applyAudioSampleRate(), applySettings(), and processOneSample().

◆ m_channelId

const QString AMDemod::m_channelId = "AMDemod"
static

Definition at line 164 of file amdemod.h.

Referenced by AMDemod(), and AMDemodPlugin::initPlugin().

◆ m_channelIdURI

const QString AMDemod::m_channelIdURI = "sdrangel.channel.amdemod"
static

Definition at line 163 of file amdemod.h.

Referenced by AMDemodGUI::AMDemodGUI(), and AMDemodPlugin::initPlugin().

◆ m_channelizer

DownChannelizer* AMDemod::m_channelizer
private

Definition at line 184 of file amdemod.h.

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

◆ m_deviceAPI

DeviceAPI* AMDemod::m_deviceAPI
private

Definition at line 182 of file amdemod.h.

Referenced by AMDemod(), applySettings(), getNumberOfDeviceStreams(), and ~AMDemod().

◆ m_inputFrequencyOffset

int AMDemod::m_inputFrequencyOffset
private

Definition at line 187 of file amdemod.h.

Referenced by AMDemod(), applyChannelSettings(), applySettings(), and start().

◆ m_inputSampleRate

int AMDemod::m_inputSampleRate
private

◆ m_interpolator

Interpolator AMDemod::m_interpolator
private

Definition at line 193 of file amdemod.h.

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

◆ m_interpolatorDistance

Real AMDemod::m_interpolatorDistance
private

Definition at line 194 of file amdemod.h.

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

◆ m_interpolatorDistanceRemain

Real AMDemod::m_interpolatorDistanceRemain
private

Definition at line 195 of file amdemod.h.

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

◆ m_lowpass

Lowpass<Real> AMDemod::m_lowpass
private

Definition at line 210 of file amdemod.h.

Referenced by applyAudioSampleRate(), applySettings(), and processOneSample().

◆ m_magsq

double AMDemod::m_magsq
private

Definition at line 201 of file amdemod.h.

Referenced by AMDemod(), getMagSq(), getMagSqLevels(), and processOneSample().

◆ m_magsqCount

int AMDemod::m_magsqCount
private

Definition at line 204 of file amdemod.h.

Referenced by getMagSqLevels(), and processOneSample().

◆ m_magSqLevelStore

MagSqLevelsStore AMDemod::m_magSqLevelStore
private

Definition at line 205 of file amdemod.h.

Referenced by getMagSqLevels().

◆ m_magsqPeak

double AMDemod::m_magsqPeak
private

Definition at line 203 of file amdemod.h.

Referenced by getMagSqLevels(), and processOneSample().

◆ m_magsqSum

double AMDemod::m_magsqSum
private

Definition at line 202 of file amdemod.h.

Referenced by getMagSqLevels(), and processOneSample().

◆ m_movingAverage

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

Definition at line 207 of file amdemod.h.

Referenced by processOneSample().

◆ m_nco

NCO AMDemod::m_nco
private

Definition at line 192 of file amdemod.h.

Referenced by applyChannelSettings(), and feed().

◆ m_networkManager

QNetworkAccessManager* AMDemod::m_networkManager
private

Definition at line 225 of file amdemod.h.

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

◆ m_networkRequest

QNetworkRequest AMDemod::m_networkRequest
private

Definition at line 226 of file amdemod.h.

Referenced by webapiReverseSendSettings().

◆ m_pll

PhaseLockComplex AMDemod::m_pll
private

◆ m_pllFilt

Lowpass<std::complex<float> > AMDemod::m_pllFilt
private

Definition at line 211 of file amdemod.h.

Referenced by AMDemod(), applyAudioSampleRate(), and processOneSample().

◆ m_running

bool AMDemod::m_running
private

Definition at line 190 of file amdemod.h.

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

◆ m_settings

AMDemodSettings AMDemod::m_settings
private

◆ m_settingsMutex

QMutex AMDemod::m_settingsMutex
private

Definition at line 228 of file amdemod.h.

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

◆ m_squelchCount

uint32_t AMDemod::m_squelchCount
private

Definition at line 198 of file amdemod.h.

Referenced by processOneSample(), and start().

◆ m_squelchDelayLine

DoubleBufferFIFO<Real> AMDemod::m_squelchDelayLine
private

Definition at line 200 of file amdemod.h.

Referenced by applyAudioSampleRate(), and processOneSample().

◆ m_squelchLevel

Real AMDemod::m_squelchLevel
private

Definition at line 197 of file amdemod.h.

Referenced by applySettings(), and processOneSample().

◆ m_squelchOpen

bool AMDemod::m_squelchOpen
private

Definition at line 199 of file amdemod.h.

Referenced by getSquelchOpen(), processOneSample(), and webapiFormatChannelReport().

◆ m_syncAMAGC

MagAGC AMDemod::m_syncAMAGC
private

Definition at line 217 of file amdemod.h.

Referenced by AMDemod(), applyAudioSampleRate(), and processOneSample().

◆ m_syncAMBuff

Real AMDemod::m_syncAMBuff[2 *1024]
private

Definition at line 215 of file amdemod.h.

Referenced by processOneSample().

◆ m_syncAMBuffIndex

uint32_t AMDemod::m_syncAMBuffIndex
private

Definition at line 216 of file amdemod.h.

Referenced by AMDemod(), applySettings(), and processOneSample().

◆ m_threadedChannelizer

ThreadedBasebandSampleSink* AMDemod::m_threadedChannelizer
private

Definition at line 183 of file amdemod.h.

Referenced by AMDemod(), applySettings(), and ~AMDemod().

◆ m_udpBlockSize

const int AMDemod::m_udpBlockSize = 512
staticprivate

Definition at line 223 of file amdemod.h.

◆ m_volumeAGC

SimpleAGC<4800> AMDemod::m_volumeAGC
private

Definition at line 208 of file amdemod.h.

Referenced by applyAudioSampleRate(), applySettings(), and processOneSample().

◆ SSBFilter

fftfilt* AMDemod::SSBFilter
private

Definition at line 214 of file amdemod.h.

Referenced by AMDemod(), processOneSample(), and ~AMDemod().


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