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

#include <udpsource.h>

+ Inheritance diagram for UDPSource:
+ Collaboration diagram for UDPSource:

Classes

class  MsgConfigureChannelizer
 
class  MsgConfigureUDPSource
 
class  MsgResetReadIndex
 
class  MsgUDPSourceSpectrum
 

Signals

void levelChanged (qreal rmsLevel, qreal peakLevel, int numSamples)
 

Public Member Functions

 UDPSource (DeviceAPI *deviceAPI)
 
virtual ~UDPSource ()
 
virtual void destroy ()
 
void setSpectrumSink (BasebandSampleSink *spectrum)
 
virtual void start ()
 
virtual void stop ()
 
virtual void pull (Sample &sample)
 
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)
 
double getMagSq () const
 
double getInMagSq () const
 
int32_t getBufferGauge () const
 
bool getSquelchOpen () const
 
void setSpectrum (bool enabled)
 
void resetReadIndex ()
 
- Public Member Functions inherited from BasebandSampleSource
 BasebandSampleSource ()
 
virtual ~BasebandSampleSource ()
 
virtual void pullAudio (int nbSamples)
 
void feed (SampleSourceFifo *sampleFifo, int nbSamples)
 
SampleSourceFifogetSampleSourceFifo ()
 
MessageQueuegetInputMessageQueue ()
 Get the queue for asynchronous inbound communication. More...
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
MessageQueuegetMessageQueueToGUI ()
 
void setDeviceSampleSourceFifo (SampleSourceFifo *deviceSampleFifo)
 
- 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.channeltx.udpsource"
 
static const QString m_channelId = "UDPSource"
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void applyChannelSettings (int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
 
void applySettings (const UDPSourceSettings &settings, bool force=false)
 
void modulateSample ()
 
void calculateLevel (Real sample)
 
void calculateLevel (Complex sample)
 
void webapiFormatChannelSettings (SWGSDRangel::SWGChannelSettings &response, const UDPSourceSettings &settings)
 
void webapiFormatChannelReport (SWGSDRangel::SWGChannelReport &response)
 
void webapiReverseSendSettings (QList< QString > &channelSettingsKeys, const UDPSourceSettings &settings, bool force)
 
void calculateSquelch (double value)
 
void initSquelch (bool open)
 
void readMonoSample (qint16 &t)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSourcem_threadedChannelizer
 
UpChannelizerm_channelizer
 
int m_basebandSampleRate
 
Real m_outputSampleRate
 
int m_inputFrequencyOffset
 
UDPSourceSettings m_settings
 
Real m_squelch
 
NCO m_carrierNco
 
Complex m_modSample
 
BasebandSampleSinkm_spectrum
 
bool m_spectrumEnabled
 
SampleVector m_sampleBuffer
 
int m_spectrumChunkSize
 
int m_spectrumChunkCounter
 
Interpolator m_interpolator
 
Real m_interpolatorDistance
 
Real m_interpolatorDistanceRemain
 
bool m_interpolatorConsumed
 
double m_magsq
 
double m_inMagsq
 
MovingAverage< double > m_movingAverage
 
MovingAverage< double > m_inMovingAverage
 
UDPSourceUDPHandler m_udpHandler
 
Real m_actualInputSampleRate
 sample rate with UDP buffer skew compensation More...
 
double m_sampleRateSum
 
int m_sampleRateAvgCounter
 
int m_levelCalcCount
 
Real m_peakLevel
 
double m_levelSum
 
int m_levelNbSamples
 
bool m_squelchOpen
 
int m_squelchOpenCount
 
int m_squelchCloseCount
 
int m_squelchThreshold
 
float m_modPhasor
 Phasor for FM modulation. More...
 
fftfiltm_SSBFilter
 Complex filter for SSB modulation. More...
 
Complexm_SSBFilterBuffer
 
int m_SSBFilterBufferIndex
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 
QMutex m_settingsMutex
 

Static Private Attributes

static const int m_sampleRateAverageItems = 17
 
static const int m_ssbFftLen = 1024
 

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 BasebandSampleSource
void handleInputMessages ()
 
void handleWriteToFifo (int nbSamples)
 
void handleWriteToDeviceFifo (int nbSamples)
 
- Protected Member Functions inherited from BasebandSampleSource
void handleWriteToFifo (SampleSourceFifo *sampleFifo, int nbSamples)
 
- Protected Attributes inherited from BasebandSampleSource
MessageQueue m_inputMessageQueue
 Queue for asynchronous inbound communication. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 
SampleSourceFifo m_sampleFifo
 Internal FIFO for multi-channel processing. More...
 
SampleSourceFifom_deviceSampleFifo
 Reference to the device FIFO for single channel processing. More...
 

Detailed Description

Definition at line 42 of file udpsource.h.

Constructor & Destructor Documentation

◆ UDPSource()

UDPSource::UDPSource ( DeviceAPI deviceAPI)

Definition at line 44 of file udpsource.cpp.

References DeviceAPI::addChannelSource(), DeviceAPI::addChannelSourceAPI(), applyChannelSettings(), applySettings(), m_basebandSampleRate, m_channelId, m_channelizer, m_deviceAPI, m_inputFrequencyOffset, BasebandSampleSource::m_inputMessageQueue, UDPSourceSettings::m_inputSampleRate, UDPSourceSettings::m_lowCutoff, m_networkManager, m_outputSampleRate, UDPSourceSettings::m_rfBandwidth, m_settings, m_ssbFftLen, m_SSBFilter, m_SSBFilterBuffer, m_threadedChannelizer, m_udpHandler, networkManagerFinished(), and UDPSourceUDPHandler::setFeedbackMessageQueue().

Referenced by UDPSource::MsgConfigureChannelizer::MsgConfigureChannelizer().

44  :
46  m_deviceAPI(deviceAPI),
47  m_basebandSampleRate(48000),
48  m_outputSampleRate(48000),
50  m_squelch(1e-6),
51  m_spectrum(0),
52  m_spectrumEnabled(false),
53  m_spectrumChunkSize(2160),
55  m_magsq(1e-10),
56  m_movingAverage(16, 1e-10),
57  m_inMovingAverage(480, 1e-10),
58  m_sampleRateSum(0),
61  m_peakLevel(0.0f),
62  m_levelSum(0.0f),
63  m_levelNbSamples(480),
64  m_squelchOpen(false),
67  m_squelchThreshold(4800),
68  m_modPhasor(0.0f),
70  m_settingsMutex(QMutex::Recursive)
71 {
72  setObjectName(m_channelId);
73 
76  m_SSBFilterBuffer = new Complex[m_ssbFftLen>>1]; // filter returns data exactly half of its size
77 
80 
81  m_channelizer = new UpChannelizer(this);
85 
86  m_networkManager = new QNetworkAccessManager();
87  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
88 }
float m_modPhasor
Phasor for FM modulation.
Definition: udpsource.h:241
int m_basebandSampleRate
Definition: udpsource.h:200
int m_spectrumChunkCounter
Definition: udpsource.h:214
Complex * m_SSBFilterBuffer
Definition: udpsource.h:243
static const QString m_channelId
Definition: udpsource.h:144
void applySettings(const UDPSourceSettings &settings, bool force=false)
Definition: udpsource.cpp:492
int m_inputFrequencyOffset
Definition: udpsource.h:202
Real m_squelch
Definition: udpsource.h:205
static const QString m_channelIdURI
Definition: udpsource.h:143
Exposes a single source stream (output, Tx)
Definition: channelapi.h:42
void networkManagerFinished(QNetworkReply *reply)
Definition: udpsource.cpp:947
int m_SSBFilterBufferIndex
Definition: udpsource.h:244
Real m_outputSampleRate
Definition: udpsource.h:201
BasebandSampleSink * m_spectrum
Definition: udpsource.h:210
UDPSourceSettings m_settings
Definition: udpsource.h:203
static const int m_ssbFftLen
Definition: udpsource.h:252
int m_squelchThreshold
Definition: udpsource.h:239
void addChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Add a channel source (Tx)
Definition: deviceapi.cpp:138
QNetworkAccessManager * m_networkManager
Definition: udpsource.h:246
QMutex m_settingsMutex
Definition: udpsource.h:249
MovingAverage< double > m_inMovingAverage
Definition: udpsource.h:224
MovingAverage< double > m_movingAverage
Definition: udpsource.h:223
double m_sampleRateSum
Definition: udpsource.h:228
double m_magsq
Definition: udpsource.h:221
int m_spectrumChunkSize
Definition: udpsource.h:213
UDPSourceUDPHandler m_udpHandler
Definition: udpsource.h:226
int m_levelNbSamples
Definition: udpsource.h:234
int m_levelCalcCount
Definition: udpsource.h:231
double m_levelSum
Definition: udpsource.h:233
fftfilt * m_SSBFilter
Complex filter for SSB modulation.
Definition: udpsource.h:242
bool m_squelchOpen
Definition: udpsource.h:236
bool m_spectrumEnabled
Definition: udpsource.h:211
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
int m_squelchOpenCount
Definition: udpsource.h:237
int m_squelchCloseCount
Definition: udpsource.h:238
int m_sampleRateAvgCounter
Definition: udpsource.h:229
DeviceAPI * m_deviceAPI
Definition: udpsource.h:196
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: udpsource.cpp:462
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
ThreadedBasebandSampleSource * m_threadedChannelizer
Definition: udpsource.h:197
void addChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:174
Real m_peakLevel
Definition: udpsource.h:232
std::complex< Real > Complex
Definition: dsptypes.h:43
UpChannelizer * m_channelizer
Definition: udpsource.h:198
void setFeedbackMessageQueue(MessageQueue *messageQueue)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~UDPSource()

UDPSource::~UDPSource ( )
virtual

Definition at line 90 of file udpsource.cpp.

References m_channelizer, m_deviceAPI, m_networkManager, m_SSBFilter, m_SSBFilterBuffer, m_threadedChannelizer, networkManagerFinished(), DeviceAPI::removeChannelSource(), and DeviceAPI::removeChannelSourceAPI().

Referenced by UDPSource::MsgConfigureChannelizer::MsgConfigureChannelizer().

91 {
92  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
93  delete m_networkManager;
96  delete m_threadedChannelizer;
97  delete m_channelizer;
98  delete m_SSBFilter;
99  delete[] m_SSBFilterBuffer;
100 }
Complex * m_SSBFilterBuffer
Definition: udpsource.h:243
void removeChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:181
void removeChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Remove a channel source (Tx)
Definition: deviceapi.cpp:147
void networkManagerFinished(QNetworkReply *reply)
Definition: udpsource.cpp:947
QNetworkAccessManager * m_networkManager
Definition: udpsource.h:246
fftfilt * m_SSBFilter
Complex filter for SSB modulation.
Definition: udpsource.h:242
DeviceAPI * m_deviceAPI
Definition: udpsource.h:196
ThreadedBasebandSampleSource * m_threadedChannelizer
Definition: udpsource.h:197
UpChannelizer * m_channelizer
Definition: udpsource.h:198
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applyChannelSettings()

void UDPSource::applyChannelSettings ( int  basebandSampleRate,
int  outputSampleRate,
int  inputFrequencyOffset,
bool  force = false 
)
private

Definition at line 462 of file udpsource.cpp.

References Interpolator::create(), UDPSourceSettings::m_autoRWBalance, m_basebandSampleRate, m_carrierNco, m_inputFrequencyOffset, UDPSourceSettings::m_inputSampleRate, m_interpolator, m_interpolatorConsumed, m_interpolatorDistance, m_interpolatorDistanceRemain, m_outputSampleRate, UDPSourceSettings::m_rfBandwidth, m_settings, m_settingsMutex, and NCO::setFreq().

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

463 {
464  qDebug() << "UDPSource::applyChannelSettings:"
465  << " basebandSampleRate: " << basebandSampleRate
466  << " outputSampleRate: " << outputSampleRate
467  << " inputFrequencyOffset: " << inputFrequencyOffset;
468 
469  if ((inputFrequencyOffset != m_inputFrequencyOffset) ||
470  (outputSampleRate != m_outputSampleRate) || force)
471  {
472  m_settingsMutex.lock();
473  m_carrierNco.setFreq(inputFrequencyOffset, outputSampleRate);
474  m_settingsMutex.unlock();
475  }
476 
477  if (((outputSampleRate != m_outputSampleRate) && (!m_settings.m_autoRWBalance)) || force)
478  {
479  m_settingsMutex.lock();
481  m_interpolatorConsumed = false;
484  m_settingsMutex.unlock();
485  }
486 
487  m_basebandSampleRate = basebandSampleRate;
488  m_outputSampleRate = outputSampleRate;
489  m_inputFrequencyOffset = inputFrequencyOffset;
490 }
int m_basebandSampleRate
Definition: udpsource.h:200
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
int m_inputFrequencyOffset
Definition: udpsource.h:202
Real m_outputSampleRate
Definition: udpsource.h:201
Real m_interpolatorDistanceRemain
Definition: udpsource.h:218
UDPSourceSettings m_settings
Definition: udpsource.h:203
QMutex m_settingsMutex
Definition: udpsource.h:249
void setFreq(Real freq, Real sampleRate)
Definition: nco.cpp:49
NCO m_carrierNco
Definition: udpsource.h:207
bool m_interpolatorConsumed
Definition: udpsource.h:219
Real m_interpolatorDistance
Definition: udpsource.h:217
Interpolator m_interpolator
Definition: udpsource.h:216
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySettings()

void UDPSource::applySettings ( const UDPSourceSettings settings,
bool  force = false 
)
private

Definition at line 492 of file udpsource.cpp.

References UDPSourceUDPHandler::configureUDPLink(), Interpolator::create(), fftfilt::create_filter(), initSquelch(), m_actualInputSampleRate, UDPSourceSettings::m_amModFactor, UDPSourceSettings::m_autoRWBalance, UDPSourceSettings::m_channelMute, UDPSourceSettings::m_fmDeviation, UDPSourceSettings::m_gainIn, UDPSourceSettings::m_gainOut, m_inMovingAverage, UDPSourceSettings::m_inputFrequencyOffset, UDPSourceSettings::m_inputSampleRate, m_interpolator, m_interpolatorConsumed, m_interpolatorDistance, m_interpolatorDistanceRemain, m_levelCalcCount, m_levelNbSamples, m_levelSum, UDPSourceSettings::m_lowCutoff, m_outputSampleRate, m_peakLevel, UDPSourceSettings::m_reverseAPIAddress, UDPSourceSettings::m_reverseAPIChannelIndex, UDPSourceSettings::m_reverseAPIDeviceIndex, UDPSourceSettings::m_reverseAPIPort, UDPSourceSettings::m_rfBandwidth, UDPSourceSettings::m_sampleFormat, m_sampleRateAvgCounter, m_sampleRateSum, m_settings, m_settingsMutex, m_spectrumChunkCounter, m_spectrumChunkSize, UDPSourceSettings::m_squelch, m_squelch, UDPSourceSettings::m_squelchEnabled, UDPSourceSettings::m_squelchGate, m_squelchOpen, m_squelchThreshold, m_SSBFilter, UDPSourceSettings::m_stereoInput, UDPSourceSettings::m_udpAddress, m_udpHandler, UDPSourceSettings::m_udpPort, UDPSourceSettings::m_useReverseAPI, CalcDb::powerFromdB(), UDPSourceUDPHandler::resetReadIndex(), MovingAverage< Type >::resize(), UDPSourceUDPHandler::resizeBuffer(), UDPSourceUDPHandler::setAutoRWBalance(), and webapiReverseSendSettings().

Referenced by handleMessage(), and UDPSource().

493 {
494  qDebug() << "UDPSource::applySettings:"
495  << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
496  << " m_sampleFormat: " << settings.m_sampleFormat
497  << " m_inputSampleRate: " << settings.m_inputSampleRate
498  << " m_rfBandwidth: " << settings.m_rfBandwidth
499  << " m_lowCutoff: " << settings.m_lowCutoff
500  << " m_fmDeviation: " << settings.m_fmDeviation
501  << " m_amModFactor: " << settings.m_amModFactor
502  << " m_udpAddressStr: " << settings.m_udpAddress
503  << " m_udpPort: " << settings.m_udpPort
504  << " m_channelMute: " << settings.m_channelMute
505  << " m_gainIn: " << settings.m_gainIn
506  << " m_gainOut: " << settings.m_gainOut
507  << " m_squelchGate: " << settings.m_squelchGate
508  << " m_squelch: " << settings.m_squelch << "dB"
509  << " m_squelchEnabled: " << settings.m_squelchEnabled
510  << " m_autoRWBalance: " << settings.m_autoRWBalance
511  << " m_stereoInput: " << settings.m_stereoInput
512  << " force: " << force;
513 
514  QList<QString> reverseAPIKeys;
515 
516  if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
517  reverseAPIKeys.append("inputFrequencyOffset");
518  }
519  if ((settings.m_sampleFormat != m_settings.m_sampleFormat) || force) {
520  reverseAPIKeys.append("sampleFormat");
521  }
522  if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force) {
523  reverseAPIKeys.append("inputSampleRate");
524  }
525  if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
526  reverseAPIKeys.append("rfBandwidth");
527  }
528  if ((settings.m_lowCutoff != m_settings.m_lowCutoff) || force) {
529  reverseAPIKeys.append("lowCutoff");
530  }
531  if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force) {
532  reverseAPIKeys.append("fmDeviation");
533  }
534  if ((settings.m_amModFactor != m_settings.m_amModFactor) || force) {
535  reverseAPIKeys.append("amModFactor");
536  }
537  if ((settings.m_udpAddress != m_settings.m_udpAddress) || force) {
538  reverseAPIKeys.append("udpAddress");
539  }
540  if ((settings.m_udpPort != m_settings.m_udpPort) || force) {
541  reverseAPIKeys.append("udpPort");
542  }
543  if ((settings.m_channelMute != m_settings.m_channelMute) || force) {
544  reverseAPIKeys.append("channelMute");
545  }
546  if ((settings.m_gainIn != m_settings.m_gainIn) || force) {
547  reverseAPIKeys.append("gainIn");
548  }
549  if ((settings.m_gainOut != m_settings.m_gainOut) || force) {
550  reverseAPIKeys.append("gainOut");
551  }
552  if ((settings.m_squelchGate != m_settings.m_squelchGate) || force) {
553  reverseAPIKeys.append("squelchGate");
554  }
555  if ((settings.m_squelch != m_settings.m_squelch) || force) {
556  reverseAPIKeys.append("squelch");
557  }
558  if ((settings.m_squelchEnabled != m_settings.m_squelchEnabled) || force) {
559  reverseAPIKeys.append("squelchEnabled");
560  }
561  if ((settings.m_autoRWBalance != m_settings.m_autoRWBalance) || force) {
562  reverseAPIKeys.append("autoRWBalance");
563  }
564  if ((settings.m_stereoInput != m_settings.m_stereoInput) || force) {
565  reverseAPIKeys.append("stereoInput");
566  }
567 
568  if((settings.m_rfBandwidth != m_settings.m_rfBandwidth) ||
569  (settings.m_lowCutoff != m_settings.m_lowCutoff) ||
570  (settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force)
571  {
572  m_settingsMutex.lock();
574  m_interpolatorConsumed = false;
576  m_interpolator.create(48, settings.m_inputSampleRate, settings.m_rfBandwidth / 2.2, 3.0);
579  m_sampleRateSum = 0.0;
581  m_spectrumChunkSize = settings.m_inputSampleRate * 0.05; // 50 ms chunk
583  m_levelNbSamples = settings.m_inputSampleRate * 0.01; // every 10 ms
584  m_levelCalcCount = 0;
585  m_peakLevel = 0.0f;
586  m_levelSum = 0.0f;
588  m_inMovingAverage.resize(settings.m_inputSampleRate * 0.01, 1e-10); // 10 ms
589  m_squelchThreshold = settings.m_inputSampleRate * settings.m_squelchGate;
591  m_SSBFilter->create_filter(settings.m_lowCutoff / settings.m_inputSampleRate, settings.m_rfBandwidth / settings.m_inputSampleRate);
592  m_settingsMutex.unlock();
593  }
594 
595  if ((settings.m_squelch != m_settings.m_squelch) || force)
596  {
598  }
599 
600  if ((settings.m_squelchGate != m_settings.m_squelchGate) || force)
601  {
604  }
605 
606  if ((settings.m_udpAddress != m_settings.m_udpAddress) ||
607  (settings.m_udpPort != m_settings.m_udpPort) || force)
608  {
609  m_settingsMutex.lock();
611  m_settingsMutex.unlock();
612  }
613 
614  if ((settings.m_channelMute != m_settings.m_channelMute) || force)
615  {
616  if (!settings.m_channelMute) {
618  }
619  }
620 
621  if ((settings.m_autoRWBalance != m_settings.m_autoRWBalance) || force)
622  {
623  m_settingsMutex.lock();
625 
626  if (!settings.m_autoRWBalance)
627  {
629  m_interpolatorConsumed = false;
631  m_interpolator.create(48, settings.m_inputSampleRate, settings.m_rfBandwidth / 2.2, 3.0);
634  }
635 
636  m_settingsMutex.unlock();
637  }
638 
639  if (settings.m_useReverseAPI)
640  {
641  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
646  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
647  }
648 
649  m_settings = settings;
650 }
int m_spectrumChunkCounter
Definition: udpsource.h:214
void initSquelch(bool open)
Definition: udpsource.h:306
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
Real m_squelch
Definition: udpsource.h:205
Real m_outputSampleRate
Definition: udpsource.h:201
Real m_interpolatorDistanceRemain
Definition: udpsource.h:218
UDPSourceSettings m_settings
Definition: udpsource.h:203
void setAutoRWBalance(bool autoRWBalance)
int m_squelchThreshold
Definition: udpsource.h:239
QMutex m_settingsMutex
Definition: udpsource.h:249
MovingAverage< double > m_inMovingAverage
Definition: udpsource.h:224
double m_sampleRateSum
Definition: udpsource.h:228
Real m_squelch
squared magnitude
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const UDPSourceSettings &settings, bool force)
Definition: udpsource.cpp:858
Real m_actualInputSampleRate
sample rate with UDP buffer skew compensation
Definition: udpsource.h:227
int m_spectrumChunkSize
Definition: udpsource.h:213
UDPSourceUDPHandler m_udpHandler
Definition: udpsource.h:226
int m_levelNbSamples
Definition: udpsource.h:234
int m_levelCalcCount
Definition: udpsource.h:231
double m_levelSum
Definition: udpsource.h:233
fftfilt * m_SSBFilter
Complex filter for SSB modulation.
Definition: udpsource.h:242
bool m_squelchOpen
Definition: udpsource.h:236
void configureUDPLink(const QString &address, quint16 port)
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
uint16_t m_reverseAPIDeviceIndex
bool m_interpolatorConsumed
Definition: udpsource.h:219
int m_sampleRateAvgCounter
Definition: udpsource.h:229
uint16_t m_reverseAPIChannelIndex
Real m_interpolatorDistance
Definition: udpsource.h:217
void resizeBuffer(float sampleRate)
Interpolator m_interpolator
Definition: udpsource.h:216
Real m_squelchGate
seconds
SampleFormat m_sampleFormat
Real m_peakLevel
Definition: udpsource.h:232
float Real
Definition: dsptypes.h:42
void resize(int historySize, Type initial)
Definition: movingaverage.h:16
static double powerFromdB(double powerdB)
Definition: db.cpp:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateLevel() [1/2]

void UDPSource::calculateLevel ( Real  sample)
private

Definition at line 291 of file udpsource.cpp.

References levelChanged(), m_levelCalcCount, m_levelNbSamples, m_levelSum, m_peakLevel, leansdr::max(), and sqrt().

Referenced by modulateSample().

292 {
294  {
295  m_peakLevel = std::max(std::fabs(m_peakLevel), sample);
296  m_levelSum += sample * sample;
298  }
299  else
300  {
301  qreal rmsLevel = m_levelSum > 0.0 ? sqrt(m_levelSum / m_levelNbSamples) : 0.0;
302  //qDebug("NFMMod::calculateLevel: %f %f", rmsLevel, m_peakLevel);
303  emit levelChanged(rmsLevel, m_peakLevel, m_levelNbSamples);
304  m_peakLevel = 0.0f;
305  m_levelSum = 0.0f;
306  m_levelCalcCount = 0;
307  }
308 }
int m_levelNbSamples
Definition: udpsource.h:234
int m_levelCalcCount
Definition: udpsource.h:231
double m_levelSum
Definition: udpsource.h:233
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2283
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
Real m_peakLevel
Definition: udpsource.h:232
T max(const T &x, const T &y)
Definition: framework.h:446
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateLevel() [2/2]

void UDPSource::calculateLevel ( Complex  sample)
private

Definition at line 310 of file udpsource.cpp.

References abs(), levelChanged(), m_levelCalcCount, m_levelNbSamples, m_levelSum, m_peakLevel, leansdr::max(), SDR_TX_SCALED, SDR_TX_SCALEF, and sqrt().

311 {
312  Real t = std::abs(sample);
313 
315  {
316  m_peakLevel = std::max(std::fabs(m_peakLevel), t);
317  m_levelSum += (t * t);
319  }
320  else
321  {
322  qreal rmsLevel = m_levelSum > 0.0 ? sqrt((m_levelSum/(SDR_TX_SCALED*SDR_TX_SCALED)) / m_levelNbSamples) : 0.0;
324  m_peakLevel = 0.0f;
325  m_levelSum = 0.0f;
326  m_levelCalcCount = 0;
327  }
328 }
Fixed< IntType, IntBits > abs(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2313
#define SDR_TX_SCALEF
Definition: dsptypes.h:39
int m_levelNbSamples
Definition: udpsource.h:234
int m_levelCalcCount
Definition: udpsource.h:231
double m_levelSum
Definition: udpsource.h:233
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2283
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
Real m_peakLevel
Definition: udpsource.h:232
float Real
Definition: dsptypes.h:42
#define SDR_TX_SCALED
Definition: dsptypes.h:40
T max(const T &x, const T &y)
Definition: framework.h:446
+ Here is the call graph for this function:

◆ calculateSquelch()

void UDPSource::calculateSquelch ( double  value)
inlineprivate

Definition at line 264 of file udpsource.h.

References UDPSourceSettings::m_squelchEnabled, and m_squelchThreshold.

Referenced by modulateSample().

265  {
266  if ((!m_settings.m_squelchEnabled) || (value > m_squelch))
267  {
268  if (m_squelchThreshold == 0)
269  {
270  m_squelchOpen = true;
271  }
272  else
273  {
275  {
277  }
278  else
279  {
281  m_squelchOpen = true;
282  }
283  }
284  }
285  else
286  {
287  if (m_squelchThreshold == 0)
288  {
289  m_squelchOpen = false;
290  }
291  else
292  {
293  if (m_squelchCloseCount > 0)
294  {
296  }
297  else
298  {
299  m_squelchOpenCount = 0;
300  m_squelchOpen = false;
301  }
302  }
303  }
304  }
Real m_squelch
Definition: udpsource.h:205
UDPSourceSettings m_settings
Definition: udpsource.h:203
int m_squelchThreshold
Definition: udpsource.h:239
bool m_squelchOpen
Definition: udpsource.h:236
int m_squelchOpenCount
Definition: udpsource.h:237
int m_squelchCloseCount
Definition: udpsource.h:238
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements ChannelAPI.

Definition at line 657 of file udpsource.cpp.

References UDPSource::MsgConfigureUDPSource::create(), UDPSourceSettings::deserialize(), BasebandSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and UDPSourceSettings::resetToDefaults().

Referenced by getCenterFrequency().

658 {
659  if (m_settings.deserialize(data))
660  {
661  MsgConfigureUDPSource *msg = MsgConfigureUDPSource::create(m_settings, true);
663  return true;
664  }
665  else
666  {
668  MsgConfigureUDPSource *msg = MsgConfigureUDPSource::create(m_settings, true);
670  return false;
671  }
672 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
UDPSourceSettings m_settings
Definition: udpsource.h:203
bool deserialize(const QByteArray &data)
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
static MsgConfigureUDPSource * create(const UDPSourceSettings &settings, bool force)
Definition: udpsource.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

virtual void UDPSource::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 95 of file udpsource.h.

95 { delete this; }

◆ getBufferGauge()

int32_t UDPSource::getBufferGauge ( ) const
inline

Definition at line 137 of file udpsource.h.

References UDPSourceUDPHandler::getBufferGauge(), and m_udpHandler.

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

137 { return m_udpHandler.getBufferGauge(); }
int32_t getBufferGauge() const
UDPSourceUDPHandler m_udpHandler
Definition: udpsource.h:226
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCenterFrequency()

virtual qint64 UDPSource::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 106 of file udpsource.h.

References deserialize(), UDPSourceSettings::m_inputFrequencyOffset, UDPSource::MsgConfigureUDPSource::m_settings, and serialize().

UDPSourceSettings m_settings
Definition: udpsource.h:203
+ Here is the call graph for this function:

◆ getIdentifier()

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

Implements ChannelAPI.

Definition at line 104 of file udpsource.h.

104 { id = objectName(); }

◆ getInMagSq()

double UDPSource::getInMagSq ( ) const
inline

Definition at line 136 of file udpsource.h.

References m_inMagsq.

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

136 { return m_inMagsq; }
double m_inMagsq
Definition: udpsource.h:222
+ Here is the caller graph for this function:

◆ getMagSq()

double UDPSource::getMagSq ( ) const
inline

Definition at line 135 of file udpsource.h.

References m_magsq.

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

135 { return m_magsq; }
double m_magsq
Definition: udpsource.h:221
+ Here is the caller graph for this function:

◆ getNbSinkStreams()

virtual int UDPSource::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 111 of file udpsource.h.

111 { return 1; }

◆ getNbSourceStreams()

virtual int UDPSource::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 112 of file udpsource.h.

112 { return 0; }

◆ getSquelchOpen()

bool UDPSource::getSquelchOpen ( ) const
inline

Definition at line 138 of file udpsource.h.

References m_squelchOpen, resetReadIndex(), and setSpectrum().

Referenced by UDPSourceGUI::tick().

138 { return m_squelchOpen; }
bool m_squelchOpen
Definition: udpsource.h:236
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStreamCenterFrequency()

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

Implements ChannelAPI.

Definition at line 114 of file udpsource.h.

References UDPSourceSettings::m_inputFrequencyOffset, UDPSource::MsgConfigureUDPSource::m_settings, webapiReportGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

115  {
116  (void) streamIndex;
117  (void) sinkElseSource;
119  }
UDPSourceSettings m_settings
Definition: udpsource.h:203
+ Here is the call graph for this function:

◆ getTitle()

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

Implements ChannelAPI.

Definition at line 105 of file udpsource.h.

References UDPSource::MsgConfigureUDPSource::m_settings, and UDPSourceSettings::m_title.

105 { title = m_settings.m_title; }
UDPSourceSettings m_settings
Definition: udpsource.h:203

◆ handleMessage()

bool UDPSource::handleMessage ( const Message cmd)
virtual

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

Implements BasebandSampleSource.

Definition at line 330 of file udpsource.cpp.

References applyChannelSettings(), applySettings(), UpChannelizer::configure(), UpChannelizer::MsgChannelizerNotification::getBasebandSampleRate(), UDPSource::MsgConfigureChannelizer::getCenterFrequency(), UDPSourceMessages::MsgSampleRateCorrection::getCorrectionFactor(), UDPSource::MsgUDPSourceSpectrum::getEnabled(), UDPSource::MsgConfigureUDPSource::getForce(), UpChannelizer::MsgChannelizerNotification::getFrequencyOffset(), BasebandSampleSource::getInputMessageQueue(), UDPSourceMessages::MsgSampleRateCorrection::getRawDeltaRatio(), UpChannelizer::MsgChannelizerNotification::getSampleRate(), UDPSource::MsgConfigureChannelizer::getSampleRate(), UDPSource::MsgConfigureUDPSource::getSettings(), BasebandSampleSink::handleMessage(), m_actualInputSampleRate, m_channelizer, UDPSourceSettings::m_inputSampleRate, m_interpolatorConsumed, m_interpolatorDistance, m_interpolatorDistanceRemain, m_outputSampleRate, m_sampleRateAverageItems, m_sampleRateAvgCounter, m_sampleRateSum, m_settings, m_settingsMutex, m_spectrum, m_spectrumEnabled, m_udpHandler, Message::match(), and UDPSourceUDPHandler::resetReadIndex().

Referenced by setSpectrumSink().

331 {
333  {
335  qDebug() << "UDPSource::handleMessage: MsgChannelizerNotification";
336 
338 
339  return true;
340  }
341  else if (MsgConfigureChannelizer::match(cmd))
342  {
343  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
344  qDebug() << "UDPSource::handleMessage: MsgConfigureChannelizer:"
345  << " sampleRate: " << cfg.getSampleRate()
346  << " centerFrequency: " << cfg.getCenterFrequency();
347 
349  cfg.getSampleRate(),
350  cfg.getCenterFrequency());
351 
352  return true;
353  }
354  else if (MsgConfigureUDPSource::match(cmd))
355  {
356  MsgConfigureUDPSource& cfg = (MsgConfigureUDPSource&) cmd;
357  qDebug() << "UDPSource::handleMessage: MsgConfigureUDPSource";
358 
359  applySettings(cfg.getSettings(), cfg.getForce());
360 
361  return true;
362  }
364  {
367 
368  // exclude values too way out nominal sample rate (20%)
369  if ((newSampleRate < m_settings.m_inputSampleRate * 1.2) && (newSampleRate > m_settings.m_inputSampleRate * 0.8))
370  {
371  m_actualInputSampleRate = newSampleRate;
372 
373  if ((cfg.getRawDeltaRatio() > -0.05) && (cfg.getRawDeltaRatio() < 0.05))
374  {
376  {
379  }
380  }
381  else
382  {
383  m_sampleRateSum = 0.0;
385  }
386 
388  {
389  float avgRate = m_sampleRateSum / m_sampleRateAverageItems;
390  qDebug("UDPSource::handleMessage: MsgSampleRateCorrection: corr: %+.6f new rate: %.0f: avg rate: %.0f",
391  cfg.getCorrectionFactor(),
393  avgRate);
394  m_actualInputSampleRate = avgRate;
395  m_sampleRateSum = 0.0;
397  }
398 // else
399 // {
400 // qDebug("UDPSource::handleMessage: MsgSampleRateCorrection: corr: %+.6f new rate: %.0f",
401 // cfg.getCorrectionFactor(),
402 // m_actualInputSampleRate);
403 // }
404 
405  m_settingsMutex.lock();
407  m_interpolatorConsumed = false;
409  //m_interpolator.create(48, m_actualInputSampleRate, m_settings.m_rfBandwidth / 2.2, 3.0); // causes clicking: leaving at standard frequency
410  m_settingsMutex.unlock();
411  }
412 
413  return true;
414  }
415  else if (MsgUDPSourceSpectrum::match(cmd))
416  {
417  MsgUDPSourceSpectrum& spc = (MsgUDPSourceSpectrum&) cmd;
418  m_spectrumEnabled = spc.getEnabled();
419  qDebug() << "UDPSource::handleMessage: MsgUDPSourceSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
420 
421  return true;
422  }
423  else if (MsgResetReadIndex::match(cmd))
424  {
425  m_settingsMutex.lock();
427  m_settingsMutex.unlock();
428 
429  qDebug() << "UDPSource::handleMessage: MsgResetReadIndex";
430 
431  return true;
432  }
433  else if (DSPSignalNotification::match(cmd))
434  {
435  return true;
436  }
437  else
438  {
439  if(m_spectrum != 0)
440  {
441  return m_spectrum->handleMessage(cmd);
442  }
443  else
444  {
445  return false;
446  }
447  }
448 }
void applySettings(const UDPSourceSettings &settings, bool force=false)
Definition: udpsource.cpp:492
static const int m_sampleRateAverageItems
Definition: udpsource.h:251
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
Real m_outputSampleRate
Definition: udpsource.h:201
BasebandSampleSink * m_spectrum
Definition: udpsource.h:210
Real m_interpolatorDistanceRemain
Definition: udpsource.h:218
UDPSourceSettings m_settings
Definition: udpsource.h:203
QMutex m_settingsMutex
Definition: udpsource.h:249
double m_sampleRateSum
Definition: udpsource.h:228
Real m_actualInputSampleRate
sample rate with UDP buffer skew compensation
Definition: udpsource.h:227
UDPSourceUDPHandler m_udpHandler
Definition: udpsource.h:226
virtual bool handleMessage(const Message &cmd)=0
Processing of a message. Returns true if message has actually been processed.
bool m_spectrumEnabled
Definition: udpsource.h:211
static bool match(const Message *message)
Definition: message.cpp:45
bool m_interpolatorConsumed
Definition: udpsource.h:219
int m_sampleRateAvgCounter
Definition: udpsource.h:229
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: udpsource.cpp:462
Real m_interpolatorDistance
Definition: udpsource.h:217
UpChannelizer * m_channelizer
Definition: udpsource.h:198
float Real
Definition: dsptypes.h:42
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSquelch()

void UDPSource::initSquelch ( bool  open)
inlineprivate

Definition at line 306 of file udpsource.h.

References m_squelchThreshold.

Referenced by applySettings(), modulateSample(), and pull().

307  {
308  if (open)
309  {
310  m_squelchOpen = true;
313  }
314  else
315  {
316  m_squelchOpen = false;
317  m_squelchOpenCount = 0;
319  }
320  }
int m_squelchThreshold
Definition: udpsource.h:239
bool m_squelchOpen
Definition: udpsource.h:236
int m_squelchOpenCount
Definition: udpsource.h:237
int m_squelchCloseCount
Definition: udpsource.h:238
+ Here is the caller graph for this function:

◆ levelChanged

void UDPSource::levelChanged ( qreal  rmsLevel,
qreal  peakLevel,
int  numSamples 
)
signal

Level changed

Parameters
rmsLevelRMS level in range 0.0 - 1.0
peakLevelPeak level in range 0.0 - 1.0
numSamplesNumber of audio samples analyzed

Referenced by calculateLevel().

+ Here is the caller graph for this function:

◆ modulateSample()

void UDPSource::modulateSample ( )
private

Definition at line 159 of file udpsource.cpp.

References MovingAverage< Type >::average(), calculateLevel(), calculateSquelch(), cos(), MovingAverage< Type >::feed(), BasebandSampleSink::feed(), UDPSourceSettings::FormatAM, UDPSourceSettings::FormatLSB, UDPSourceSettings::FormatNFM, UDPSourceSettings::FormatSnLE, UDPSourceSettings::FormatUSB, initSquelch(), UDPSourceSettings::m_amModFactor, UDPSourceSettings::m_fmDeviation, UDPSourceSettings::m_gainOut, Sample::m_imag, m_inMagsq, m_inMovingAverage, UDPSourceSettings::m_inputSampleRate, m_modPhasor, m_modSample, M_PI, Sample::m_real, m_sampleBuffer, UDPSourceSettings::m_sampleFormat, m_settings, m_spectrum, m_spectrumChunkCounter, m_spectrumChunkSize, m_spectrumEnabled, m_squelchOpen, m_SSBFilter, m_SSBFilterBuffer, m_SSBFilterBufferIndex, m_udpHandler, readMonoSample(), UDPSourceUDPHandler::readSample(), fftfilt::runSSB(), SDR_TX_SCALED, SDR_TX_SCALEF, and sin().

Referenced by pull().

160 {
161  if (m_settings.m_sampleFormat == UDPSourceSettings::FormatSnLE) // Linear I/Q transponding
162  {
163  Sample s;
164 
166 
167  uint64_t magsq = s.m_real * s.m_real + s.m_imag * s.m_imag;
170 
172 
173  if (m_squelchOpen)
174  {
178  }
179  else
180  {
181  m_modSample.real(0.0f);
182  m_modSample.imag(0.0f);
183  }
184  }
186  {
187  qint16 t;
188  readMonoSample(t);
189 
190  m_inMovingAverage.feed((t*t)/1073741824.0);
192 
194 
195  if (m_squelchOpen)
196  {
199  m_modSample.imag(sin(m_modPhasor) * 0.3162292f * SDR_TX_SCALEF * m_settings.m_gainOut);
201  }
202  else
203  {
204  m_modSample.real(0.0f);
205  m_modSample.imag(0.0f);
206  }
207  }
209  {
210  qint16 t;
211  readMonoSample(t);
212  m_inMovingAverage.feed((t*t)/(SDR_TX_SCALED*SDR_TX_SCALED));
214 
216 
217  if (m_squelchOpen)
218  {
219  m_modSample.real(((t / SDR_TX_SCALEF)*m_settings.m_amModFactor*m_settings.m_gainOut + 1.0f) * (SDR_TX_SCALEF/2)); // modulate and scale zero frequency carrier
220  m_modSample.imag(0.0f);
222  }
223  else
224  {
225  m_modSample.real(0.0f);
226  m_modSample.imag(0.0f);
227  }
228  }
230  {
231  qint16 t;
232  Complex c, ci;
233  fftfilt::cmplx *filtered;
234  int n_out = 0;
235 
236  readMonoSample(t);
237  m_inMovingAverage.feed((t*t)/(SDR_TX_SCALED*SDR_TX_SCALED));
239 
241 
242  if (m_squelchOpen)
243  {
244  ci.real((t / SDR_TX_SCALEF) * m_settings.m_gainOut);
245  ci.imag(0.0f);
246 
248 
249  if (n_out > 0)
250  {
251  memcpy((void *) m_SSBFilterBuffer, (const void *) filtered, n_out*sizeof(Complex));
253  }
254 
255  c = m_SSBFilterBuffer[m_SSBFilterBufferIndex];
256  m_modSample.real(m_SSBFilterBuffer[m_SSBFilterBufferIndex].real() * SDR_TX_SCALEF);
257  m_modSample.imag(m_SSBFilterBuffer[m_SSBFilterBufferIndex].imag() * SDR_TX_SCALEF);
259 
261  }
262  else
263  {
264  m_modSample.real(0.0f);
265  m_modSample.imag(0.0f);
266  }
267  }
268  else
269  {
270  m_modSample.real(0.0f);
271  m_modSample.imag(0.0f);
272  initSquelch(false);
273  }
274 
276  {
277  Sample s;
278  s.m_real = (FixReal) m_modSample.real();
279  s.m_imag = (FixReal) m_modSample.imag();
280  m_sampleBuffer.push_back(s);
282  }
283  else if (m_spectrum)
284  {
285  m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), false);
286  m_sampleBuffer.clear();
288  }
289 }
float m_modPhasor
Phasor for FM modulation.
Definition: udpsource.h:241
int m_spectrumChunkCounter
Definition: udpsource.h:214
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
Complex * m_SSBFilterBuffer
Definition: udpsource.h:243
void feed(Type value)
Definition: movingaverage.h:24
void initSquelch(bool open)
Definition: udpsource.h:306
int m_SSBFilterBufferIndex
Definition: udpsource.h:244
BasebandSampleSink * m_spectrum
Definition: udpsource.h:210
UDPSourceSettings m_settings
Definition: udpsource.h:203
Complex m_modSample
Definition: udpsource.h:208
#define M_PI
Definition: rdsdemod.cpp:27
Type average() const
Definition: movingaverage.h:43
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool positiveOnly)=0
MovingAverage< double > m_inMovingAverage
Definition: udpsource.h:224
std::complex< float > cmplx
Definition: fftfilt.h:21
void readMonoSample(qint16 &t)
Definition: udpsource.h:322
void readSample(qint16 &t)
audio mono
int m_spectrumChunkSize
Definition: udpsource.h:213
#define SDR_TX_SCALEF
Definition: dsptypes.h:39
UDPSourceUDPHandler m_udpHandler
Definition: udpsource.h:226
fftfilt * m_SSBFilter
Complex filter for SSB modulation.
Definition: udpsource.h:242
bool m_squelchOpen
Definition: udpsource.h:236
bool m_spectrumEnabled
Definition: udpsource.h:211
FixReal m_real
Definition: dsptypes.h:64
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2265
int runSSB(const cmplx &in, cmplx **out, bool usb, bool getDC=true)
Definition: fftfilt.cpp:284
double m_inMagsq
Definition: udpsource.h:222
FixReal m_imag
Definition: dsptypes.h:65
SampleFormat m_sampleFormat
SampleVector m_sampleBuffer
Definition: udpsource.h:212
void calculateSquelch(double value)
Definition: udpsource.h:264
std::complex< Real > Complex
Definition: dsptypes.h:43
#define SDR_TX_SCALED
Definition: dsptypes.h:40
qint16 FixReal
Definition: dsptypes.h:35
void calculateLevel(Real sample)
Definition: udpsource.cpp:291
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void UDPSource::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 947 of file udpsource.cpp.

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

948 {
949  QNetworkReply::NetworkError replyError = reply->error();
950 
951  if (replyError)
952  {
953  qWarning() << "UDPSource::networkManagerFinished:"
954  << " error(" << (int) replyError
955  << "): " << replyError
956  << ": " << reply->errorString();
957  return;
958  }
959 
960  QString answer = reply->readAll();
961  answer.chop(1); // remove last \n
962  qDebug("UDPSource::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
963 }
+ Here is the caller graph for this function:

◆ pull()

void UDPSource::pull ( Sample sample)
virtual

Implements BasebandSampleSource.

Definition at line 113 of file udpsource.cpp.

References MovingAverage< Type >::average(), Interpolator::decimate(), MovingAverage< Type >::feed(), initSquelch(), Interpolator::interpolate(), m_carrierNco, UDPSourceSettings::m_channelMute, Sample::m_imag, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_magsq, m_modSample, m_movingAverage, Sample::m_real, m_settings, m_settingsMutex, modulateSample(), NCO::nextIQ(), and SDR_TX_SCALED.

Referenced by setSpectrumSink().

114 {
116  {
117  sample.m_real = 0.0f;
118  sample.m_imag = 0.0f;
119  initSquelch(false);
120  return;
121  }
122 
123  Complex ci;
124 
125  m_settingsMutex.lock();
126 
127  if (m_interpolatorDistance > 1.0f) // decimate
128  {
129  modulateSample();
130 
132  {
133  modulateSample();
134  }
135  }
136  else
137  {
139  {
140  modulateSample();
141  }
142  }
143 
145 
146  ci *= m_carrierNco.nextIQ(); // shift to carrier frequency
147 
148  m_settingsMutex.unlock();
149 
150  double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
151  magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
152  m_movingAverage.feed(magsq);
154 
155  sample.m_real = (FixReal) ci.real();
156  sample.m_imag = (FixReal) ci.imag();
157 }
Complex nextIQ()
Return next complex sample.
Definition: nco.cpp:61
bool decimate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:38
void feed(Type value)
Definition: movingaverage.h:24
void initSquelch(bool open)
Definition: udpsource.h:306
bool interpolate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:53
Real m_interpolatorDistanceRemain
Definition: udpsource.h:218
UDPSourceSettings m_settings
Definition: udpsource.h:203
Complex m_modSample
Definition: udpsource.h:208
Type average() const
Definition: movingaverage.h:43
QMutex m_settingsMutex
Definition: udpsource.h:249
MovingAverage< double > m_movingAverage
Definition: udpsource.h:223
double m_magsq
Definition: udpsource.h:221
FixReal m_real
Definition: dsptypes.h:64
NCO m_carrierNco
Definition: udpsource.h:207
Real m_interpolatorDistance
Definition: udpsource.h:217
Interpolator m_interpolator
Definition: udpsource.h:216
FixReal m_imag
Definition: dsptypes.h:65
void modulateSample()
Definition: udpsource.cpp:159
std::complex< Real > Complex
Definition: dsptypes.h:43
#define SDR_TX_SCALED
Definition: dsptypes.h:40
qint16 FixReal
Definition: dsptypes.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readMonoSample()

void UDPSource::readMonoSample ( qint16 &  t)
inlineprivate

Definition at line 322 of file udpsource.h.

References AudioSample::l, UDPSourceSettings::m_gainIn, UDPSourceSettings::m_stereoInput, AudioSample::r, and UDPSourceUDPHandler::readSample().

Referenced by modulateSample().

323  {
324 
326  {
327  AudioSample a;
329  t = ((a.l + a.r) * m_settings.m_gainIn) / 2;
330  }
331  else
332  {
334  t *= m_settings.m_gainIn;
335  }
336  }
UDPSourceSettings m_settings
Definition: udpsource.h:203
void readSample(qint16 &t)
audio mono
UDPSourceUDPHandler m_udpHandler
Definition: udpsource.h:226
qint16 r
Definition: dsptypes.h:92
qint16 l
Definition: dsptypes.h:91
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetReadIndex()

void UDPSource::resetReadIndex ( )

Definition at line 456 of file udpsource.cpp.

References UDPSource::MsgResetReadIndex::create(), BasebandSampleSource::getInputMessageQueue(), and MessageQueue::push().

Referenced by getSquelchOpen(), and UDPSourceGUI::on_resetUDPReadIndex_clicked().

457 {
459  getInputMessageQueue()->push(cmd);
460 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgResetReadIndex * create()
Definition: udpsource.h:184
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray UDPSource::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 652 of file udpsource.cpp.

References m_settings, and UDPSourceSettings::serialize().

Referenced by getCenterFrequency().

653 {
654  return m_settings.serialize();
655 }
UDPSourceSettings m_settings
Definition: udpsource.h:203
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSpectrum()

void UDPSource::setSpectrum ( bool  enabled)

Definition at line 450 of file udpsource.cpp.

References UDPSource::MsgUDPSourceSpectrum::create(), BasebandSampleSource::getInputMessageQueue(), and MessageQueue::push().

Referenced by getSquelchOpen(), and UDPSourceGUI::onWidgetRolled().

451 {
452  Message* cmd = MsgUDPSourceSpectrum::create(enabled);
453  getInputMessageQueue()->push(cmd);
454 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
static MsgUDPSourceSpectrum * create(bool enabled)
Definition: udpsource.h:165
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSpectrumSink()

void UDPSource::setSpectrumSink ( BasebandSampleSink spectrum)
inline

Definition at line 97 of file udpsource.h.

References handleMessage(), m_spectrum, pull(), start(), and stop().

Referenced by UDPSourceGUI::UDPSourceGUI().

97 { m_spectrum = spectrum; }
BasebandSampleSink * m_spectrum
Definition: udpsource.h:210
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

void UDPSource::start ( )
virtual

Implements BasebandSampleSource.

Definition at line 102 of file udpsource.cpp.

References applyChannelSettings(), m_basebandSampleRate, m_inputFrequencyOffset, m_outputSampleRate, m_udpHandler, and UDPSourceUDPHandler::start().

Referenced by setSpectrumSink().

103 {
106 }
int m_basebandSampleRate
Definition: udpsource.h:200
int m_inputFrequencyOffset
Definition: udpsource.h:202
Real m_outputSampleRate
Definition: udpsource.h:201
UDPSourceUDPHandler m_udpHandler
Definition: udpsource.h:226
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: udpsource.cpp:462
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void UDPSource::stop ( )
virtual

Implements BasebandSampleSource.

Definition at line 108 of file udpsource.cpp.

References m_udpHandler, and UDPSourceUDPHandler::stop().

Referenced by setSpectrumSink().

109 {
110  m_udpHandler.stop();
111 }
UDPSourceUDPHandler m_udpHandler
Definition: udpsource.h:226
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatChannelReport()

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

Definition at line 849 of file udpsource.cpp.

References CalcDb::dbPower(), getBufferGauge(), getInMagSq(), getMagSq(), SWGSDRangel::SWGChannelReport::getUdpSourceReport(), m_outputSampleRate, m_squelchOpen, SWGSDRangel::SWGUDPSourceReport::setBufferGauge(), SWGSDRangel::SWGUDPSourceReport::setChannelPowerDb(), SWGSDRangel::SWGUDPSourceReport::setChannelSampleRate(), SWGSDRangel::SWGUDPSourceReport::setInputPowerDb(), and SWGSDRangel::SWGUDPSourceReport::setSquelch().

Referenced by webapiReportGet().

850 {
853  response.getUdpSourceReport()->setSquelch(m_squelchOpen ? 1 : 0);
856 }
double getInMagSq() const
Definition: udpsource.h:136
static double dbPower(double magsq, double floor=1e-12)
Definition: db.cpp:22
void setChannelSampleRate(qint32 channel_sample_rate)
Real m_outputSampleRate
Definition: udpsource.h:201
void setBufferGauge(qint32 buffer_gauge)
int32_t getBufferGauge() const
Definition: udpsource.h:137
bool m_squelchOpen
Definition: udpsource.h:236
void setInputPowerDb(float input_power_db)
double getMagSq() const
Definition: udpsource.h:135
SWGUDPSourceReport * getUdpSourceReport()
void setChannelPowerDb(float channel_power_db)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatChannelSettings()

void UDPSource::webapiFormatChannelSettings ( SWGSDRangel::SWGChannelSettings response,
const UDPSourceSettings settings 
)
private

Definition at line 803 of file udpsource.cpp.

References SWGSDRangel::SWGUDPSourceSettings::getReverseApiAddress(), SWGSDRangel::SWGUDPSourceSettings::getTitle(), SWGSDRangel::SWGUDPSourceSettings::getUdpAddress(), SWGSDRangel::SWGChannelSettings::getUdpSourceSettings(), UDPSourceSettings::m_amModFactor, UDPSourceSettings::m_autoRWBalance, UDPSourceSettings::m_channelMute, UDPSourceSettings::m_fmDeviation, UDPSourceSettings::m_gainIn, UDPSourceSettings::m_gainOut, UDPSourceSettings::m_inputFrequencyOffset, UDPSourceSettings::m_inputSampleRate, UDPSourceSettings::m_lowCutoff, UDPSourceSettings::m_reverseAPIAddress, UDPSourceSettings::m_reverseAPIChannelIndex, UDPSourceSettings::m_reverseAPIDeviceIndex, UDPSourceSettings::m_reverseAPIPort, UDPSourceSettings::m_rfBandwidth, UDPSourceSettings::m_rgbColor, UDPSourceSettings::m_sampleFormat, UDPSourceSettings::m_squelch, UDPSourceSettings::m_squelchEnabled, UDPSourceSettings::m_squelchGate, UDPSourceSettings::m_stereoInput, UDPSourceSettings::m_title, UDPSourceSettings::m_udpAddress, UDPSourceSettings::m_udpPort, UDPSourceSettings::m_useReverseAPI, SWGSDRangel::SWGUDPSourceSettings::setAmModFactor(), SWGSDRangel::SWGUDPSourceSettings::setAutoRwBalance(), SWGSDRangel::SWGUDPSourceSettings::setChannelMute(), SWGSDRangel::SWGUDPSourceSettings::setFmDeviation(), SWGSDRangel::SWGUDPSourceSettings::setGainIn(), SWGSDRangel::SWGUDPSourceSettings::setGainOut(), SWGSDRangel::SWGUDPSourceSettings::setInputFrequencyOffset(), SWGSDRangel::SWGUDPSourceSettings::setInputSampleRate(), SWGSDRangel::SWGUDPSourceSettings::setLowCutoff(), SWGSDRangel::SWGUDPSourceSettings::setReverseApiAddress(), SWGSDRangel::SWGUDPSourceSettings::setReverseApiChannelIndex(), SWGSDRangel::SWGUDPSourceSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGUDPSourceSettings::setReverseApiPort(), SWGSDRangel::SWGUDPSourceSettings::setRfBandwidth(), SWGSDRangel::SWGUDPSourceSettings::setRgbColor(), SWGSDRangel::SWGUDPSourceSettings::setSampleFormat(), SWGSDRangel::SWGUDPSourceSettings::setSquelch(), SWGSDRangel::SWGUDPSourceSettings::setSquelchEnabled(), SWGSDRangel::SWGUDPSourceSettings::setSquelchGate(), SWGSDRangel::SWGUDPSourceSettings::setStereoInput(), SWGSDRangel::SWGUDPSourceSettings::setTitle(), SWGSDRangel::SWGUDPSourceSettings::setUdpAddress(), SWGSDRangel::SWGUDPSourceSettings::setUdpPort(), and SWGSDRangel::SWGUDPSourceSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

804 {
805  response.getUdpSourceSettings()->setSampleFormat((int) settings.m_sampleFormat);
808  response.getUdpSourceSettings()->setRfBandwidth(settings.m_rfBandwidth);
809  response.getUdpSourceSettings()->setLowCutoff(settings.m_lowCutoff);
810  response.getUdpSourceSettings()->setFmDeviation(settings.m_fmDeviation);
811  response.getUdpSourceSettings()->setAmModFactor(settings.m_amModFactor);
812  response.getUdpSourceSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
813  response.getUdpSourceSettings()->setGainIn(settings.m_gainIn);
814  response.getUdpSourceSettings()->setGainOut(settings.m_gainOut);
815  response.getUdpSourceSettings()->setSquelch(settings.m_squelch);
816  response.getUdpSourceSettings()->setSquelchGate(settings.m_squelchGate);
817  response.getUdpSourceSettings()->setSquelchEnabled(settings.m_squelchEnabled ? 1 : 0);
818  response.getUdpSourceSettings()->setAutoRwBalance(settings.m_autoRWBalance ? 1 : 0);
819  response.getUdpSourceSettings()->setStereoInput(settings.m_stereoInput ? 1 : 0);
820  response.getUdpSourceSettings()->setRgbColor(settings.m_rgbColor);
821 
822  if (response.getUdpSourceSettings()->getUdpAddress()) {
823  *response.getUdpSourceSettings()->getUdpAddress() = settings.m_udpAddress;
824  } else {
825  response.getUdpSourceSettings()->setUdpAddress(new QString(settings.m_udpAddress));
826  }
827 
828  response.getUdpSourceSettings()->setUdpPort(settings.m_udpPort);
829 
830  if (response.getUdpSourceSettings()->getTitle()) {
831  *response.getUdpSourceSettings()->getTitle() = settings.m_title;
832  } else {
833  response.getUdpSourceSettings()->setTitle(new QString(settings.m_title));
834  }
835 
836  response.getUdpSourceSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
837 
838  if (response.getUdpSourceSettings()->getReverseApiAddress()) {
840  } else {
841  response.getUdpSourceSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
842  }
843 
847 }
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setFmDeviation(qint32 fm_deviation)
void setReverseApiAddress(QString *reverse_api_address)
void setSampleFormat(qint32 sample_format)
void setReverseApiPort(qint32 reverse_api_port)
SWGUDPSourceSettings * getUdpSourceSettings()
void setUdpAddress(QString *udp_address)
void setStereoInput(qint32 stereo_input)
void setAmModFactor(float am_mod_factor)
void setInputSampleRate(float input_sample_rate)
Real m_squelch
squared magnitude
void setUseReverseApi(qint32 use_reverse_api)
void setSquelchEnabled(qint32 squelch_enabled)
uint16_t m_reverseAPIDeviceIndex
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setAutoRwBalance(qint32 auto_rw_balance)
uint16_t m_reverseAPIChannelIndex
Real m_squelchGate
seconds
SampleFormat m_sampleFormat
void setChannelMute(qint32 channel_mute)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from ChannelAPI.

Definition at line 792 of file udpsource.cpp.

References SWGSDRangel::SWGChannelReport::getUdpSourceReport(), SWGSDRangel::SWGUDPSourceReport::init(), SWGSDRangel::SWGChannelReport::setUdpSourceReport(), and webapiFormatChannelReport().

Referenced by getStreamCenterFrequency().

795 {
796  (void) errorMessage;
798  response.getUdpSourceReport()->init();
799  webapiFormatChannelReport(response);
800  return 200;
801 }
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
Definition: udpsource.cpp:849
SWGUDPSourceReport * getUdpSourceReport()
void setUdpSourceReport(SWGUDPSourceReport *udp_source_report)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 858 of file udpsource.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), ChannelAPI::getDeviceSetIndex(), ChannelAPI::getIndexInDeviceSet(), SWGSDRangel::SWGChannelSettings::getUdpSourceSettings(), UDPSourceSettings::m_amModFactor, UDPSourceSettings::m_autoRWBalance, UDPSourceSettings::m_channelMute, UDPSourceSettings::m_fmDeviation, UDPSourceSettings::m_gainIn, UDPSourceSettings::m_gainOut, UDPSourceSettings::m_inputFrequencyOffset, UDPSourceSettings::m_inputSampleRate, UDPSourceSettings::m_lowCutoff, m_networkManager, m_networkRequest, UDPSourceSettings::m_reverseAPIAddress, UDPSourceSettings::m_reverseAPIChannelIndex, UDPSourceSettings::m_reverseAPIDeviceIndex, UDPSourceSettings::m_reverseAPIPort, UDPSourceSettings::m_rfBandwidth, UDPSourceSettings::m_rgbColor, UDPSourceSettings::m_sampleFormat, UDPSourceSettings::m_squelch, UDPSourceSettings::m_squelchEnabled, UDPSourceSettings::m_squelchGate, UDPSourceSettings::m_stereoInput, UDPSourceSettings::m_title, UDPSourceSettings::m_udpAddress, UDPSourceSettings::m_udpPort, SWGSDRangel::SWGUDPSourceSettings::setAmModFactor(), SWGSDRangel::SWGUDPSourceSettings::setAutoRwBalance(), SWGSDRangel::SWGUDPSourceSettings::setChannelMute(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGUDPSourceSettings::setFmDeviation(), SWGSDRangel::SWGUDPSourceSettings::setGainIn(), SWGSDRangel::SWGUDPSourceSettings::setGainOut(), SWGSDRangel::SWGUDPSourceSettings::setInputFrequencyOffset(), SWGSDRangel::SWGUDPSourceSettings::setInputSampleRate(), SWGSDRangel::SWGUDPSourceSettings::setLowCutoff(), SWGSDRangel::SWGChannelSettings::setOriginatorChannelIndex(), SWGSDRangel::SWGChannelSettings::setOriginatorDeviceSetIndex(), SWGSDRangel::SWGUDPSourceSettings::setRfBandwidth(), SWGSDRangel::SWGUDPSourceSettings::setRgbColor(), SWGSDRangel::SWGUDPSourceSettings::setSampleFormat(), SWGSDRangel::SWGUDPSourceSettings::setSquelch(), SWGSDRangel::SWGUDPSourceSettings::setSquelchEnabled(), SWGSDRangel::SWGUDPSourceSettings::setSquelchGate(), SWGSDRangel::SWGUDPSourceSettings::setStereoInput(), SWGSDRangel::SWGUDPSourceSettings::setTitle(), SWGSDRangel::SWGUDPSourceSettings::setUdpAddress(), SWGSDRangel::SWGUDPSourceSettings::setUdpPort(), and SWGSDRangel::SWGChannelSettings::setUdpSourceSettings().

Referenced by applySettings().

859 {
861  swgChannelSettings->setDirection(1); // single source (Tx)
862  swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
863  swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
864  swgChannelSettings->setChannelType(new QString("UDPSource"));
865  swgChannelSettings->setUdpSourceSettings(new SWGSDRangel::SWGUDPSourceSettings());
866  SWGSDRangel::SWGUDPSourceSettings *swgUDPSourceSettings = swgChannelSettings->getUdpSourceSettings();
867 
868  // transfer data that has been modified. When force is on transfer all data except reverse API data
869 
870  if (channelSettingsKeys.contains("sampleFormat") || force) {
871  swgUDPSourceSettings->setSampleFormat((int) settings.m_sampleFormat);
872  }
873  if (channelSettingsKeys.contains("inputSampleRate") || force) {
874  swgUDPSourceSettings->setInputSampleRate(settings.m_inputSampleRate);
875  }
876  if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
877  swgUDPSourceSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
878  }
879  if (channelSettingsKeys.contains("rfBandwidth") || force) {
880  swgUDPSourceSettings->setRfBandwidth(settings.m_rfBandwidth);
881  }
882  if (channelSettingsKeys.contains("lowCutoff") || force) {
883  swgUDPSourceSettings->setLowCutoff(settings.m_lowCutoff);
884  }
885  if (channelSettingsKeys.contains("fmDeviation") || force) {
886  swgUDPSourceSettings->setFmDeviation(settings.m_fmDeviation);
887  }
888  if (channelSettingsKeys.contains("amModFactor") || force) {
889  swgUDPSourceSettings->setAmModFactor(settings.m_amModFactor);
890  }
891  if (channelSettingsKeys.contains("channelMute") || force) {
892  swgUDPSourceSettings->setChannelMute(settings.m_channelMute ? 1 : 0);
893  }
894  if (channelSettingsKeys.contains("gainIn") || force) {
895  swgUDPSourceSettings->setGainIn(settings.m_gainIn);
896  }
897  if (channelSettingsKeys.contains("gainOut") || force) {
898  swgUDPSourceSettings->setGainOut(settings.m_gainOut);
899  }
900  if (channelSettingsKeys.contains("squelch") || force) {
901  swgUDPSourceSettings->setSquelch(settings.m_squelch);
902  }
903  if (channelSettingsKeys.contains("squelchGate") || force) {
904  swgUDPSourceSettings->setSquelchGate(settings.m_squelchGate);
905  }
906  if (channelSettingsKeys.contains("squelchEnabled") || force) {
907  swgUDPSourceSettings->setSquelchEnabled(settings.m_squelchEnabled ? 1 : 0);
908  }
909  if (channelSettingsKeys.contains("autoRWBalance") || force) {
910  swgUDPSourceSettings->setAutoRwBalance(settings.m_autoRWBalance ? 1 : 0);
911  }
912  if (channelSettingsKeys.contains("stereoInput") || force) {
913  swgUDPSourceSettings->setStereoInput(settings.m_stereoInput ? 1 : 0);
914  }
915  if (channelSettingsKeys.contains("rgbColor") || force) {
916  swgUDPSourceSettings->setRgbColor(settings.m_rgbColor);
917  }
918  if (channelSettingsKeys.contains("udpAddress") || force) {
919  swgUDPSourceSettings->setUdpAddress(new QString(settings.m_udpAddress));
920  }
921  if (channelSettingsKeys.contains("udpPort") || force) {
922  swgUDPSourceSettings->setUdpPort(settings.m_udpPort);
923  }
924  if (channelSettingsKeys.contains("title") || force) {
925  swgUDPSourceSettings->setTitle(new QString(settings.m_title));
926  }
927 
928  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
929  .arg(settings.m_reverseAPIAddress)
930  .arg(settings.m_reverseAPIPort)
931  .arg(settings.m_reverseAPIDeviceIndex)
932  .arg(settings.m_reverseAPIChannelIndex);
933  m_networkRequest.setUrl(QUrl(channelSettingsURL));
934  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
935 
936  QBuffer *buffer=new QBuffer();
937  buffer->open((QBuffer::ReadWrite));
938  buffer->write(swgChannelSettings->asJson().toUtf8());
939  buffer->seek(0);
940 
941  // Always use PATCH to avoid passing reverse API settings
942  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
943 
944  delete swgChannelSettings;
945 }
void setOriginatorChannelIndex(qint32 originator_channel_index)
QNetworkRequest m_networkRequest
Definition: udpsource.h:247
void setFmDeviation(qint32 fm_deviation)
int getDeviceSetIndex() const
Definition: channelapi.h:89
void setSampleFormat(qint32 sample_format)
SWGUDPSourceSettings * getUdpSourceSettings()
void setUdpAddress(QString *udp_address)
void setStereoInput(qint32 stereo_input)
void setChannelType(QString *channel_type)
QNetworkAccessManager * m_networkManager
Definition: udpsource.h:246
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
void setAmModFactor(float am_mod_factor)
void setInputSampleRate(float input_sample_rate)
Real m_squelch
squared magnitude
void setSquelchEnabled(qint32 squelch_enabled)
uint16_t m_reverseAPIDeviceIndex
virtual QString asJson() override
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setAutoRwBalance(qint32 auto_rw_balance)
uint16_t m_reverseAPIChannelIndex
Real m_squelchGate
seconds
SampleFormat m_sampleFormat
int getIndexInDeviceSet() const
Definition: channelapi.h:87
void setChannelMute(qint32 channel_mute)
void setUdpSourceSettings(SWGUDPSourceSettings *udp_source_settings)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from ChannelAPI.

Definition at line 674 of file udpsource.cpp.

References SWGSDRangel::SWGChannelSettings::getUdpSourceSettings(), SWGSDRangel::SWGUDPSourceSettings::init(), m_settings, SWGSDRangel::SWGChannelSettings::setUdpSourceSettings(), and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

677 {
678  (void) errorMessage;
680  response.getUdpSourceSettings()->init();
682  return 200;
683 }
SWGUDPSourceSettings * getUdpSourceSettings()
UDPSourceSettings m_settings
Definition: udpsource.h:203
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const UDPSourceSettings &settings)
Definition: udpsource.cpp:803
void setUdpSourceSettings(SWGUDPSourceSettings *udp_source_settings)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from ChannelAPI.

Definition at line 685 of file udpsource.cpp.

References UDPSource::MsgConfigureUDPSource::create(), UDPSource::MsgConfigureChannelizer::create(), SWGSDRangel::SWGUDPSourceSettings::getAmModFactor(), SWGSDRangel::SWGUDPSourceSettings::getAutoRwBalance(), SWGSDRangel::SWGUDPSourceSettings::getChannelMute(), SWGSDRangel::SWGUDPSourceSettings::getFmDeviation(), SWGSDRangel::SWGUDPSourceSettings::getGainIn(), SWGSDRangel::SWGUDPSourceSettings::getGainOut(), SWGSDRangel::SWGUDPSourceSettings::getInputFrequencyOffset(), SWGSDRangel::SWGUDPSourceSettings::getInputSampleRate(), SWGSDRangel::SWGUDPSourceSettings::getLowCutoff(), SWGSDRangel::SWGUDPSourceSettings::getReverseApiAddress(), SWGSDRangel::SWGUDPSourceSettings::getReverseApiChannelIndex(), SWGSDRangel::SWGUDPSourceSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGUDPSourceSettings::getReverseApiPort(), SWGSDRangel::SWGUDPSourceSettings::getRfBandwidth(), SWGSDRangel::SWGUDPSourceSettings::getRgbColor(), SWGSDRangel::SWGUDPSourceSettings::getSampleFormat(), SWGSDRangel::SWGUDPSourceSettings::getSquelch(), SWGSDRangel::SWGUDPSourceSettings::getSquelchEnabled(), SWGSDRangel::SWGUDPSourceSettings::getSquelchGate(), SWGSDRangel::SWGUDPSourceSettings::getStereoInput(), SWGSDRangel::SWGUDPSourceSettings::getTitle(), SWGSDRangel::SWGUDPSourceSettings::getUdpAddress(), SWGSDRangel::SWGUDPSourceSettings::getUdpPort(), SWGSDRangel::SWGChannelSettings::getUdpSourceSettings(), SWGSDRangel::SWGUDPSourceSettings::getUseReverseApi(), UDPSourceSettings::m_amModFactor, UDPSourceSettings::m_autoRWBalance, UDPSourceSettings::m_channelMute, UDPSourceSettings::m_fmDeviation, UDPSourceSettings::m_gainIn, UDPSourceSettings::m_gainOut, BasebandSampleSource::m_guiMessageQueue, UDPSourceSettings::m_inputFrequencyOffset, BasebandSampleSource::m_inputMessageQueue, UDPSourceSettings::m_inputSampleRate, UDPSourceSettings::m_lowCutoff, UDPSourceSettings::m_reverseAPIAddress, UDPSourceSettings::m_reverseAPIChannelIndex, UDPSourceSettings::m_reverseAPIDeviceIndex, UDPSourceSettings::m_reverseAPIPort, UDPSourceSettings::m_rfBandwidth, UDPSourceSettings::m_rgbColor, UDPSourceSettings::m_sampleFormat, m_settings, UDPSourceSettings::m_squelch, UDPSourceSettings::m_squelchEnabled, UDPSourceSettings::m_squelchGate, UDPSourceSettings::m_stereoInput, UDPSourceSettings::m_title, UDPSourceSettings::m_udpAddress, UDPSourceSettings::m_udpPort, UDPSourceSettings::m_useReverseAPI, MessageQueue::push(), and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

690 {
691  (void) errorMessage;
692  UDPSourceSettings settings = m_settings;
693  bool frequencyOffsetChanged = false;
694 
695  if (channelSettingsKeys.contains("sampleFormat")) {
697  }
698  if (channelSettingsKeys.contains("inputSampleRate")) {
700  }
701  if (channelSettingsKeys.contains("inputFrequencyOffset"))
702  {
704  frequencyOffsetChanged = true;
705  }
706  if (channelSettingsKeys.contains("rfBandwidth")) {
707  settings.m_rfBandwidth = response.getUdpSourceSettings()->getRfBandwidth();
708  }
709  if (channelSettingsKeys.contains("lowCutoff")) {
710  settings.m_lowCutoff = response.getUdpSourceSettings()->getLowCutoff();
711  }
712  if (channelSettingsKeys.contains("fmDeviation")) {
713  settings.m_fmDeviation = response.getUdpSourceSettings()->getFmDeviation();
714  }
715  if (channelSettingsKeys.contains("amModFactor")) {
716  settings.m_amModFactor = response.getUdpSourceSettings()->getAmModFactor();
717  }
718  if (channelSettingsKeys.contains("channelMute")) {
719  settings.m_channelMute = response.getUdpSourceSettings()->getChannelMute() != 0;
720  }
721  if (channelSettingsKeys.contains("gainIn")) {
722  settings.m_gainIn = response.getUdpSourceSettings()->getGainIn();
723  }
724  if (channelSettingsKeys.contains("gainOut")) {
725  settings.m_gainOut = response.getUdpSourceSettings()->getGainOut();
726  }
727  if (channelSettingsKeys.contains("squelch")) {
728  settings.m_squelch = response.getUdpSourceSettings()->getSquelch();
729  }
730  if (channelSettingsKeys.contains("squelchGate")) {
731  settings.m_squelchGate = response.getUdpSourceSettings()->getSquelchGate();
732  }
733  if (channelSettingsKeys.contains("squelchEnabled")) {
734  settings.m_squelchEnabled = response.getUdpSourceSettings()->getSquelchEnabled() != 0;
735  }
736  if (channelSettingsKeys.contains("autoRWBalance")) {
737  settings.m_autoRWBalance = response.getUdpSourceSettings()->getAutoRwBalance() != 0;
738  }
739  if (channelSettingsKeys.contains("stereoInput")) {
740  settings.m_stereoInput = response.getUdpSourceSettings()->getStereoInput() != 0;
741  }
742  if (channelSettingsKeys.contains("rgbColor")) {
743  settings.m_rgbColor = response.getUdpSourceSettings()->getRgbColor();
744  }
745  if (channelSettingsKeys.contains("udpAddress")) {
746  settings.m_udpAddress = *response.getUdpSourceSettings()->getUdpAddress();
747  }
748  if (channelSettingsKeys.contains("udpPort")) {
749  settings.m_udpPort = response.getUdpSourceSettings()->getUdpPort();
750  }
751  if (channelSettingsKeys.contains("title")) {
752  settings.m_title = *response.getUdpSourceSettings()->getTitle();
753  }
754  if (channelSettingsKeys.contains("useReverseAPI")) {
755  settings.m_useReverseAPI = response.getUdpSourceSettings()->getUseReverseApi() != 0;
756  }
757  if (channelSettingsKeys.contains("reverseAPIAddress")) {
759  }
760  if (channelSettingsKeys.contains("reverseAPIPort")) {
762  }
763  if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
765  }
766  if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
768  }
769 
770  if (frequencyOffsetChanged)
771  {
773  settings.m_inputSampleRate,
774  settings.m_inputFrequencyOffset);
775  m_inputMessageQueue.push(msgChan);
776  }
777 
778  MsgConfigureUDPSource *msg = MsgConfigureUDPSource::create(settings, force);
780 
781  if (m_guiMessageQueue) // forward to GUI if any
782  {
783  MsgConfigureUDPSource *msgToGUI = MsgConfigureUDPSource::create(settings, force);
784  m_guiMessageQueue->push(msgToGUI);
785  }
786 
787  webapiFormatChannelSettings(response, settings);
788 
789  return 200;
790 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
SWGUDPSourceSettings * getUdpSourceSettings()
UDPSourceSettings m_settings
Definition: udpsource.h:203
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const UDPSourceSettings &settings)
Definition: udpsource.cpp:803
Real m_squelch
squared magnitude
uint16_t m_reverseAPIDeviceIndex
uint16_t m_reverseAPIChannelIndex
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
Real m_squelchGate
seconds
SampleFormat m_sampleFormat
static MsgConfigureUDPSource * create(const UDPSourceSettings &settings, bool force)
Definition: udpsource.h:53
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: udpsource.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_actualInputSampleRate

Real UDPSource::m_actualInputSampleRate
private

sample rate with UDP buffer skew compensation

Definition at line 227 of file udpsource.h.

Referenced by applySettings(), and handleMessage().

◆ m_basebandSampleRate

int UDPSource::m_basebandSampleRate
private

Definition at line 200 of file udpsource.h.

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

◆ m_carrierNco

NCO UDPSource::m_carrierNco
private

Definition at line 207 of file udpsource.h.

Referenced by applyChannelSettings(), and pull().

◆ m_channelId

const QString UDPSource::m_channelId = "UDPSource"
static

Definition at line 144 of file udpsource.h.

Referenced by UDPSourcePlugin::initPlugin(), and UDPSource().

◆ m_channelIdURI

const QString UDPSource::m_channelIdURI = "sdrangel.channeltx.udpsource"
static

Definition at line 143 of file udpsource.h.

Referenced by UDPSourcePlugin::initPlugin(), and UDPSourceGUI::UDPSourceGUI().

◆ m_channelizer

UpChannelizer* UDPSource::m_channelizer
private

Definition at line 198 of file udpsource.h.

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

◆ m_deviceAPI

DeviceAPI* UDPSource::m_deviceAPI
private

Definition at line 196 of file udpsource.h.

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

◆ m_inMagsq

double UDPSource::m_inMagsq
private

Definition at line 222 of file udpsource.h.

Referenced by getInMagSq(), and modulateSample().

◆ m_inMovingAverage

MovingAverage<double> UDPSource::m_inMovingAverage
private

Definition at line 224 of file udpsource.h.

Referenced by applySettings(), and modulateSample().

◆ m_inputFrequencyOffset

int UDPSource::m_inputFrequencyOffset
private

Definition at line 202 of file udpsource.h.

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

◆ m_interpolator

Interpolator UDPSource::m_interpolator
private

Definition at line 216 of file udpsource.h.

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

◆ m_interpolatorConsumed

bool UDPSource::m_interpolatorConsumed
private

Definition at line 219 of file udpsource.h.

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

◆ m_interpolatorDistance

Real UDPSource::m_interpolatorDistance
private

Definition at line 217 of file udpsource.h.

Referenced by applyChannelSettings(), applySettings(), handleMessage(), and pull().

◆ m_interpolatorDistanceRemain

Real UDPSource::m_interpolatorDistanceRemain
private

Definition at line 218 of file udpsource.h.

Referenced by applyChannelSettings(), applySettings(), handleMessage(), and pull().

◆ m_levelCalcCount

int UDPSource::m_levelCalcCount
private

Definition at line 231 of file udpsource.h.

Referenced by applySettings(), and calculateLevel().

◆ m_levelNbSamples

int UDPSource::m_levelNbSamples
private

Definition at line 234 of file udpsource.h.

Referenced by applySettings(), and calculateLevel().

◆ m_levelSum

double UDPSource::m_levelSum
private

Definition at line 233 of file udpsource.h.

Referenced by applySettings(), and calculateLevel().

◆ m_magsq

double UDPSource::m_magsq
private

Definition at line 221 of file udpsource.h.

Referenced by getMagSq(), and pull().

◆ m_modPhasor

float UDPSource::m_modPhasor
private

Phasor for FM modulation.

Definition at line 241 of file udpsource.h.

Referenced by modulateSample().

◆ m_modSample

Complex UDPSource::m_modSample
private

Definition at line 208 of file udpsource.h.

Referenced by modulateSample(), and pull().

◆ m_movingAverage

MovingAverage<double> UDPSource::m_movingAverage
private

Definition at line 223 of file udpsource.h.

Referenced by pull().

◆ m_networkManager

QNetworkAccessManager* UDPSource::m_networkManager
private

Definition at line 246 of file udpsource.h.

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

◆ m_networkRequest

QNetworkRequest UDPSource::m_networkRequest
private

Definition at line 247 of file udpsource.h.

Referenced by webapiReverseSendSettings().

◆ m_outputSampleRate

Real UDPSource::m_outputSampleRate
private

◆ m_peakLevel

Real UDPSource::m_peakLevel
private

Definition at line 232 of file udpsource.h.

Referenced by applySettings(), and calculateLevel().

◆ m_sampleBuffer

SampleVector UDPSource::m_sampleBuffer
private

Definition at line 212 of file udpsource.h.

Referenced by modulateSample().

◆ m_sampleRateAverageItems

const int UDPSource::m_sampleRateAverageItems = 17
staticprivate

Definition at line 251 of file udpsource.h.

Referenced by handleMessage().

◆ m_sampleRateAvgCounter

int UDPSource::m_sampleRateAvgCounter
private

Definition at line 229 of file udpsource.h.

Referenced by applySettings(), and handleMessage().

◆ m_sampleRateSum

double UDPSource::m_sampleRateSum
private

Definition at line 228 of file udpsource.h.

Referenced by applySettings(), and handleMessage().

◆ m_settings

UDPSourceSettings UDPSource::m_settings
private

◆ m_settingsMutex

QMutex UDPSource::m_settingsMutex
private

Definition at line 249 of file udpsource.h.

Referenced by applyChannelSettings(), applySettings(), handleMessage(), and pull().

◆ m_spectrum

BasebandSampleSink* UDPSource::m_spectrum
private

Definition at line 210 of file udpsource.h.

Referenced by handleMessage(), modulateSample(), and setSpectrumSink().

◆ m_spectrumChunkCounter

int UDPSource::m_spectrumChunkCounter
private

Definition at line 214 of file udpsource.h.

Referenced by applySettings(), and modulateSample().

◆ m_spectrumChunkSize

int UDPSource::m_spectrumChunkSize
private

Definition at line 213 of file udpsource.h.

Referenced by applySettings(), and modulateSample().

◆ m_spectrumEnabled

bool UDPSource::m_spectrumEnabled
private

Definition at line 211 of file udpsource.h.

Referenced by handleMessage(), and modulateSample().

◆ m_squelch

Real UDPSource::m_squelch
private

Definition at line 205 of file udpsource.h.

Referenced by applySettings().

◆ m_squelchCloseCount

int UDPSource::m_squelchCloseCount
private

Definition at line 238 of file udpsource.h.

◆ m_squelchOpen

bool UDPSource::m_squelchOpen
private

◆ m_squelchOpenCount

int UDPSource::m_squelchOpenCount
private

Definition at line 237 of file udpsource.h.

◆ m_squelchThreshold

int UDPSource::m_squelchThreshold
private

Definition at line 239 of file udpsource.h.

Referenced by applySettings(), calculateSquelch(), and initSquelch().

◆ m_ssbFftLen

const int UDPSource::m_ssbFftLen = 1024
staticprivate

Definition at line 252 of file udpsource.h.

Referenced by UDPSource().

◆ m_SSBFilter

fftfilt* UDPSource::m_SSBFilter
private

Complex filter for SSB modulation.

Definition at line 242 of file udpsource.h.

Referenced by applySettings(), modulateSample(), UDPSource(), and ~UDPSource().

◆ m_SSBFilterBuffer

Complex* UDPSource::m_SSBFilterBuffer
private

Definition at line 243 of file udpsource.h.

Referenced by modulateSample(), UDPSource(), and ~UDPSource().

◆ m_SSBFilterBufferIndex

int UDPSource::m_SSBFilterBufferIndex
private

Definition at line 244 of file udpsource.h.

Referenced by modulateSample().

◆ m_threadedChannelizer

ThreadedBasebandSampleSource* UDPSource::m_threadedChannelizer
private

Definition at line 197 of file udpsource.h.

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

◆ m_udpHandler

UDPSourceUDPHandler UDPSource::m_udpHandler
private

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