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

#include <wfmmod.h>

+ Inheritance diagram for WFMMod:
+ Collaboration diagram for WFMMod:

Classes

class  MsgConfigureChannelizer
 
class  MsgConfigureFileSourceName
 
class  MsgConfigureFileSourceSeek
 
class  MsgConfigureFileSourceStreamTiming
 
class  MsgConfigureWFMMod
 
class  MsgReportFileSourceStreamData
 
class  MsgReportFileSourceStreamTiming
 

Signals

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

Public Member Functions

 WFMMod (DeviceAPI *deviceAPI)
 
 ~WFMMod ()
 
virtual void destroy ()
 
virtual void pull (Sample &sample)
 
virtual void pullAudio (int nbSamples)
 
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)
 
double getMagSq () const
 
CWKeyergetCWKeyer ()
 
- Public Member Functions inherited from BasebandSampleSource
 BasebandSampleSource ()
 
virtual ~BasebandSampleSource ()
 
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.modwfm"
 
static const QString m_channelId = "WFMMod"
 

Private Types

enum  RateState { RSInitialFill, RSRunning }
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void applyAudioSampleRate (int sampleRate)
 
void applyChannelSettings (int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
 
void applySettings (const WFMModSettings &settings, bool force=false)
 
void pullAF (Complex &sample)
 
void calculateLevel (const Real &sample)
 
void openFileStream ()
 
void seekFileStream (int seekPercentage)
 
void webapiFormatChannelSettings (SWGSDRangel::SWGChannelSettings &response, const WFMModSettings &settings)
 
void webapiFormatChannelReport (SWGSDRangel::SWGChannelReport &response)
 
void webapiReverseSendSettings (QList< QString > &channelSettingsKeys, const WFMModSettings &settings, bool force)
 
void webapiReverseSendCWSettings (const CWKeyerSettings &settings)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSourcem_threadedChannelizer
 
UpChannelizerm_channelizer
 
int m_basebandSampleRate
 
int m_outputSampleRate
 
int m_inputFrequencyOffset
 
WFMModSettings m_settings
 
NCO m_carrierNco
 
NCOF m_toneNcoRF
 
float m_modPhasor
 baseband modulator phasor More...
 
Complex m_modSample
 
Interpolator m_interpolator
 
Real m_interpolatorDistance
 
Real m_interpolatorDistanceRemain
 
bool m_interpolatorConsumed
 
fftfiltm_rfFilter
 
fftfilt::cmplxm_rfFilterBuffer
 
int m_rfFilterBufferIndex
 
double m_magsq
 
MovingAverageUtil< double, double, 16 > m_movingAverage
 
quint32 m_audioSampleRate
 
AudioVector m_audioBuffer
 
uint m_audioBufferFill
 
AudioFifo m_audioFifo
 
SampleVector m_sampleBuffer
 
QMutex m_settingsMutex
 
std::ifstream m_ifstream
 
QString m_fileName
 
quint64 m_fileSize
 raw file size (bytes) More...
 
quint32 m_recordLength
 record length in seconds computed from file size More...
 
int m_sampleRate
 
quint32 m_levelCalcCount
 
Real m_peakLevel
 
Real m_levelSum
 
CWKeyer m_cwKeyer
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 

Static Private Attributes

static const int m_rfFilterFFTLength = 1024
 
static const int m_levelNbSamples = 480
 

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

Member Enumeration Documentation

◆ RateState

enum WFMMod::RateState
private
Enumerator
RSInitialFill 
RSRunning 

Definition at line 264 of file wfmmod.h.

264  {
266  RSRunning
267  };

Constructor & Destructor Documentation

◆ WFMMod()

WFMMod::WFMMod ( DeviceAPI deviceAPI)

Definition at line 55 of file wfmmod.cpp.

References AudioDeviceManager::addAudioSource(), DeviceAPI::addChannelSource(), DeviceAPI::addChannelSourceAPI(), applyChannelSettings(), applySettings(), DSPEngine::getAudioDeviceManager(), BasebandSampleSource::getInputMessageQueue(), AudioDeviceManager::getInputSampleRate(), DSPEngine::instance(), m_audioBuffer, m_audioBufferFill, m_audioFifo, m_audioSampleRate, m_basebandSampleRate, m_channelId, m_channelizer, m_cwKeyer, m_deviceAPI, m_inputFrequencyOffset, m_magsq, m_networkManager, m_outputSampleRate, m_rfFilter, m_rfFilterBuffer, m_rfFilterBufferIndex, m_rfFilterFFTLength, m_settings, m_threadedChannelizer, m_toneNcoRF, networkManagerFinished(), CWKeyer::reset(), NCOF::setFreq(), and CWKeyer::setSampleRate().

Referenced by WFMMod::MsgReportFileSourceStreamData::MsgReportFileSourceStreamData().

55  :
57  m_deviceAPI(deviceAPI),
58  m_basebandSampleRate(384000),
59  m_outputSampleRate(384000),
61  m_modPhasor(0.0f),
62  m_audioFifo(4800),
63  m_settingsMutex(QMutex::Recursive),
64  m_fileSize(0),
65  m_recordLength(0),
66  m_sampleRate(48000),
68  m_peakLevel(0.0f),
69  m_levelSum(0.0f)
70 {
71  setObjectName(m_channelId);
72 
73  m_rfFilter = new fftfilt(-62500.0 / 384000.0, 62500.0 / 384000.0, m_rfFilterFFTLength);
76  //memset(m_rfFilterBuffer, 0, sizeof(Complex)*(m_rfFilterFFTLength));
78 
79  m_audioBuffer.resize(1<<14);
81 
82  m_magsq = 0.0;
83 
86 
89  m_cwKeyer.reset();
90 
93 
94  m_channelizer = new UpChannelizer(this);
98 
99  m_networkManager = new QNetworkAccessManager();
100  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
101 }
double m_magsq
Definition: wfmmod.h:292
ThreadedBasebandSampleSource * m_threadedChannelizer
Definition: wfmmod.h:270
UpChannelizer * m_channelizer
Definition: wfmmod.h:271
CWKeyer m_cwKeyer
Definition: wfmmod.h:312
QNetworkAccessManager * m_networkManager
Definition: wfmmod.h:314
DeviceAPI * m_deviceAPI
Definition: wfmmod.h:269
int getInputSampleRate(int inputDeviceIndex=-1)
fftfilt::cmplx * m_rfFilterBuffer
Definition: wfmmod.h:289
NCOF m_toneNcoRF
Definition: wfmmod.h:279
fftfilt * m_rfFilter
Definition: wfmmod.h:287
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: wfmmod.cpp:449
int m_sampleRate
Definition: wfmmod.h:307
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
Exposes a single source stream (output, Tx)
Definition: channelapi.h:42
void addChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Add a channel source (Tx)
Definition: deviceapi.cpp:138
AudioVector m_audioBuffer
Definition: wfmmod.h:296
static const QString m_channelIdURI
Definition: wfmmod.h:250
void addAudioSource(AudioFifo *audioFifo, MessageQueue *sampleSourceMessageQueue, int inputDeviceIndex=-1)
Add an audio source.
quint64 m_fileSize
raw file size (bytes)
Definition: wfmmod.h:305
quint32 m_levelCalcCount
Definition: wfmmod.h:309
static const QString m_channelId
Definition: wfmmod.h:251
static DSPEngine * instance()
Definition: dspengine.cpp:51
int m_rfFilterBufferIndex
Definition: wfmmod.h:290
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
Real m_peakLevel
Definition: wfmmod.h:310
quint32 m_audioSampleRate
Definition: wfmmod.h:295
void applySettings(const WFMModSettings &settings, bool force=false)
Definition: wfmmod.cpp:485
AudioFifo m_audioFifo
Definition: wfmmod.h:298
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
static const int m_rfFilterFFTLength
Definition: wfmmod.h:288
void networkManagerFinished(QNetworkReply *reply)
Definition: wfmmod.cpp:885
void setFreq(Real freq, Real sampleRate)
Definition: ncof.cpp:51
quint32 m_recordLength
record length in seconds computed from file size
Definition: wfmmod.h:306
void addChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:174
Real m_levelSum
Definition: wfmmod.h:311
int m_basebandSampleRate
Definition: wfmmod.h:273
WFMModSettings m_settings
Definition: wfmmod.h:276
int m_outputSampleRate
Definition: wfmmod.h:274
void reset()
Definition: cwkeyer.h:109
std::complex< Real > Complex
Definition: dsptypes.h:43
float m_modPhasor
baseband modulator phasor
Definition: wfmmod.h:280
void setSampleRate(int sampleRate)
Definition: cwkeyer.cpp:186
QMutex m_settingsMutex
Definition: wfmmod.h:301
int m_inputFrequencyOffset
Definition: wfmmod.h:275
uint m_audioBufferFill
Definition: wfmmod.h:297
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~WFMMod()

WFMMod::~WFMMod ( )

Definition at line 103 of file wfmmod.cpp.

References DSPEngine::getAudioDeviceManager(), DSPEngine::instance(), m_audioFifo, m_channelizer, m_deviceAPI, m_networkManager, m_rfFilter, m_rfFilterBuffer, m_threadedChannelizer, networkManagerFinished(), AudioDeviceManager::removeAudioSource(), DeviceAPI::removeChannelSource(), and DeviceAPI::removeChannelSourceAPI().

Referenced by WFMMod::MsgReportFileSourceStreamData::MsgReportFileSourceStreamData().

104 {
105  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
106  delete m_networkManager;
110  delete m_threadedChannelizer;
111  delete m_channelizer;
112  delete m_rfFilter;
113  delete[] m_rfFilterBuffer;
114 }
ThreadedBasebandSampleSource * m_threadedChannelizer
Definition: wfmmod.h:270
UpChannelizer * m_channelizer
Definition: wfmmod.h:271
void removeChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:181
QNetworkAccessManager * m_networkManager
Definition: wfmmod.h:314
DeviceAPI * m_deviceAPI
Definition: wfmmod.h:269
fftfilt::cmplx * m_rfFilterBuffer
Definition: wfmmod.h:289
fftfilt * m_rfFilter
Definition: wfmmod.h:287
void removeChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Remove a channel source (Tx)
Definition: deviceapi.cpp:147
static DSPEngine * instance()
Definition: dspengine.cpp:51
AudioFifo m_audioFifo
Definition: wfmmod.h:298
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
void networkManagerFinished(QNetworkReply *reply)
Definition: wfmmod.cpp:885
void removeAudioSource(AudioFifo *audioFifo)
Remove an audio source.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applyAudioSampleRate()

void WFMMod::applyAudioSampleRate ( int  sampleRate)
private

Definition at line 435 of file wfmmod.cpp.

References Interpolator::create(), m_audioSampleRate, m_interpolator, m_interpolatorConsumed, m_interpolatorDistance, m_interpolatorDistanceRemain, m_outputSampleRate, WFMModSettings::m_rfBandwidth, m_settings, and m_settingsMutex.

Referenced by applySettings(), and handleMessage().

436 {
437  qDebug("WFMMod::applyAudioSampleRate: %d", sampleRate);
438 
439  m_settingsMutex.lock();
441  m_interpolatorConsumed = false;
443  m_interpolator.create(48, sampleRate, m_settings.m_rfBandwidth / 2.2, 3.0);
444  m_settingsMutex.unlock();
445 
446  m_audioSampleRate = sampleRate;
447 }
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
bool m_interpolatorConsumed
Definition: wfmmod.h:285
Real m_interpolatorDistance
Definition: wfmmod.h:283
quint32 m_audioSampleRate
Definition: wfmmod.h:295
Real m_interpolatorDistanceRemain
Definition: wfmmod.h:284
WFMModSettings m_settings
Definition: wfmmod.h:276
int m_outputSampleRate
Definition: wfmmod.h:274
Interpolator m_interpolator
Definition: wfmmod.h:282
float Real
Definition: dsptypes.h:42
QMutex m_settingsMutex
Definition: wfmmod.h:301
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyChannelSettings()

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

Definition at line 449 of file wfmmod.cpp.

References Interpolator::create(), fftfilt::create_filter(), m_audioSampleRate, m_basebandSampleRate, m_carrierNco, m_cwKeyer, m_inputFrequencyOffset, m_interpolator, m_interpolatorConsumed, m_interpolatorDistance, m_interpolatorDistanceRemain, m_outputSampleRate, WFMModSettings::m_rfBandwidth, m_rfFilter, m_settings, m_settingsMutex, WFMModSettings::m_toneFrequency, m_toneNcoRF, CWKeyer::reset(), NCO::setFreq(), NCOF::setFreq(), and CWKeyer::setSampleRate().

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

450 {
451  qDebug() << "WFMMod::applyChannelSettings:"
452  << " basebandSampleRate: " << basebandSampleRate
453  << " outputSampleRate: " << outputSampleRate
454  << " inputFrequencyOffset: " << inputFrequencyOffset;
455 
456  if ((inputFrequencyOffset != m_inputFrequencyOffset) ||
457  (outputSampleRate != m_outputSampleRate) || force)
458  {
459  m_settingsMutex.lock();
460  m_carrierNco.setFreq(inputFrequencyOffset, outputSampleRate);
461  m_settingsMutex.unlock();
462  }
463 
464  if ((outputSampleRate != m_outputSampleRate) || force)
465  {
466  m_settingsMutex.lock();
468  m_interpolatorConsumed = false;
469  m_interpolatorDistance = (Real) m_audioSampleRate / (Real) outputSampleRate;
471  Real lowCut = -(m_settings.m_rfBandwidth / 2.0) / outputSampleRate;
472  Real hiCut = (m_settings.m_rfBandwidth / 2.0) / outputSampleRate;
473  m_rfFilter->create_filter(lowCut, hiCut);
474  m_toneNcoRF.setFreq(m_settings.m_toneFrequency, outputSampleRate);
475  m_cwKeyer.setSampleRate(outputSampleRate);
476  m_cwKeyer.reset();
477  m_settingsMutex.unlock();
478  }
479 
480  m_basebandSampleRate = basebandSampleRate;
481  m_outputSampleRate = outputSampleRate;
482  m_inputFrequencyOffset = inputFrequencyOffset;
483 }
CWKeyer m_cwKeyer
Definition: wfmmod.h:312
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
NCOF m_toneNcoRF
Definition: wfmmod.h:279
fftfilt * m_rfFilter
Definition: wfmmod.h:287
bool m_interpolatorConsumed
Definition: wfmmod.h:285
Real m_interpolatorDistance
Definition: wfmmod.h:283
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
void setFreq(Real freq, Real sampleRate)
Definition: nco.cpp:49
quint32 m_audioSampleRate
Definition: wfmmod.h:295
void setFreq(Real freq, Real sampleRate)
Definition: ncof.cpp:51
Real m_interpolatorDistanceRemain
Definition: wfmmod.h:284
int m_basebandSampleRate
Definition: wfmmod.h:273
WFMModSettings m_settings
Definition: wfmmod.h:276
int m_outputSampleRate
Definition: wfmmod.h:274
void reset()
Definition: cwkeyer.h:109
Interpolator m_interpolator
Definition: wfmmod.h:282
float Real
Definition: dsptypes.h:42
NCO m_carrierNco
Definition: wfmmod.h:278
void setSampleRate(int sampleRate)
Definition: cwkeyer.cpp:186
QMutex m_settingsMutex
Definition: wfmmod.h:301
int m_inputFrequencyOffset
Definition: wfmmod.h:275
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySettings()

void WFMMod::applySettings ( const WFMModSettings settings,
bool  force = false 
)
private

Definition at line 485 of file wfmmod.cpp.

References AudioDeviceManager::addAudioSource(), applyAudioSampleRate(), Interpolator::create(), fftfilt::create_filter(), DSPEngine::getAudioDeviceManager(), AudioDeviceManager::getInputDeviceIndex(), BasebandSampleSource::getInputMessageQueue(), AudioDeviceManager::getInputSampleRate(), DSPEngine::instance(), WFMModSettings::m_afBandwidth, WFMModSettings::m_audioDeviceName, m_audioFifo, m_audioSampleRate, WFMModSettings::m_channelMute, WFMModSettings::m_fmDeviation, WFMModSettings::m_inputFrequencyOffset, m_interpolator, m_interpolatorConsumed, m_interpolatorDistance, m_interpolatorDistanceRemain, WFMModSettings::m_modAFInput, m_outputSampleRate, WFMModSettings::m_playLoop, WFMModSettings::m_reverseAPIAddress, WFMModSettings::m_reverseAPIChannelIndex, WFMModSettings::m_reverseAPIDeviceIndex, WFMModSettings::m_reverseAPIPort, WFMModSettings::m_rfBandwidth, m_rfFilter, m_settings, m_settingsMutex, WFMModSettings::m_toneFrequency, m_toneNcoRF, WFMModSettings::m_useReverseAPI, WFMModSettings::m_volumeFactor, NCOF::setFreq(), and webapiReverseSendSettings().

Referenced by handleMessage(), and WFMMod().

486 {
487  qDebug() << "WFMMod::applySettings:"
488  << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
489  << " m_rfBandwidth: " << settings.m_rfBandwidth
490  << " m_afBandwidth: " << settings.m_afBandwidth
491  << " m_fmDeviation: " << settings.m_fmDeviation
492  << " m_volumeFactor: " << settings.m_volumeFactor
493  << " m_toneFrequency: " << settings.m_toneFrequency
494  << " m_channelMute: " << settings.m_channelMute
495  << " m_playLoop: " << settings.m_playLoop
496  << " m_modAFInput: " << settings.m_modAFInput
497  << " m_audioDeviceName: " << settings.m_audioDeviceName
498  << " m_useReverseAPI: " << settings.m_useReverseAPI
499  << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
500  << " m_reverseAPIPort: " << settings.m_reverseAPIPort
501  << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
502  << " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
503  << " force: " << force;
504 
505  QList<QString> reverseAPIKeys;
506 
507  if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
508  reverseAPIKeys.append("inputFrequencyOffset");
509  }
510  if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force) {
511  reverseAPIKeys.append("fmDeviation");
512  }
513  if ((settings.m_volumeFactor != m_settings.m_volumeFactor) || force) {
514  reverseAPIKeys.append("volumeFactor");
515  }
516  if ((settings.m_channelMute != m_settings.m_channelMute) || force) {
517  reverseAPIKeys.append("channelMute");
518  }
519  if ((settings.m_playLoop != m_settings.m_playLoop) || force) {
520  reverseAPIKeys.append("playLoop");
521  }
522  if ((settings.m_modAFInput != m_settings.m_modAFInput) || force) {
523  reverseAPIKeys.append("modAFInput");
524  }
525 
526  if ((settings.m_afBandwidth != m_settings.m_afBandwidth) || force)
527  {
528  reverseAPIKeys.append("afBandwidth");
529  m_settingsMutex.lock();
531  m_interpolatorConsumed = false;
533  m_interpolator.create(48, m_audioSampleRate, settings.m_rfBandwidth / 2.2, 3.0);
534  m_settingsMutex.unlock();
535  }
536 
537  if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force)
538  {
539  reverseAPIKeys.append("rfBandwidth");
540  m_settingsMutex.lock();
541  Real lowCut = -(settings.m_rfBandwidth / 2.0) / m_outputSampleRate;
542  Real hiCut = (settings.m_rfBandwidth / 2.0) / m_outputSampleRate;
543  m_rfFilter->create_filter(lowCut, hiCut);
544  m_settingsMutex.unlock();
545  }
546 
547  if ((settings.m_toneFrequency != m_settings.m_toneFrequency) || force)
548  {
549  reverseAPIKeys.append("toneFrequency");
550  m_settingsMutex.lock();
552  m_settingsMutex.unlock();
553  }
554 
555  if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
556  {
557  reverseAPIKeys.append("audioDeviceName");
559  int audioDeviceIndex = audioDeviceManager->getInputDeviceIndex(settings.m_audioDeviceName);
560  audioDeviceManager->addAudioSource(&m_audioFifo, getInputMessageQueue(), audioDeviceIndex);
561  uint32_t audioSampleRate = audioDeviceManager->getInputSampleRate(audioDeviceIndex);
562 
563  if (m_audioSampleRate != audioSampleRate) {
564  applyAudioSampleRate(audioSampleRate);
565  }
566  }
567 
568  if (settings.m_useReverseAPI)
569  {
570  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
575  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
576  }
577 
578  m_settings = settings;
579 }
uint16_t m_reverseAPIChannelIndex
int getInputSampleRate(int inputDeviceIndex=-1)
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
NCOF m_toneNcoRF
Definition: wfmmod.h:279
fftfilt * m_rfFilter
Definition: wfmmod.h:287
bool m_interpolatorConsumed
Definition: wfmmod.h:285
Real m_interpolatorDistance
Definition: wfmmod.h:283
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
WFMModInputAF m_modAFInput
unsigned int uint32_t
Definition: rtptypes_win.h:46
void addAudioSource(AudioFifo *audioFifo, MessageQueue *sampleSourceMessageQueue, int inputDeviceIndex=-1)
Add an audio source.
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
static DSPEngine * instance()
Definition: dspengine.cpp:51
QString m_audioDeviceName
This is the audio device you get the audio samples from.
quint32 m_audioSampleRate
Definition: wfmmod.h:295
AudioFifo m_audioFifo
Definition: wfmmod.h:298
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
uint16_t m_reverseAPIPort
void setFreq(Real freq, Real sampleRate)
Definition: ncof.cpp:51
Real m_interpolatorDistanceRemain
Definition: wfmmod.h:284
int getInputDeviceIndex(const QString &deviceName) const
void applyAudioSampleRate(int sampleRate)
Definition: wfmmod.cpp:435
QString m_reverseAPIAddress
WFMModSettings m_settings
Definition: wfmmod.h:276
int m_outputSampleRate
Definition: wfmmod.h:274
Interpolator m_interpolator
Definition: wfmmod.h:282
float Real
Definition: dsptypes.h:42
qint64 m_inputFrequencyOffset
QMutex m_settingsMutex
Definition: wfmmod.h:301
uint16_t m_reverseAPIDeviceIndex
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const WFMModSettings &settings, bool force)
Definition: wfmmod.cpp:778
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateLevel()

void WFMMod::calculateLevel ( const Real sample)
private

Definition at line 268 of file wfmmod.cpp.

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

Referenced by pull().

269 {
271  {
272  m_peakLevel = std::max(std::fabs(m_peakLevel), sample);
273  m_levelSum += sample * sample;
275  }
276  else
277  {
278  qreal rmsLevel = sqrt(m_levelSum / m_levelNbSamples);
279  //qDebug("WFMMod::calculateLevel: %f %f", rmsLevel, m_peakLevel);
280  emit levelChanged(rmsLevel, m_peakLevel, m_levelNbSamples);
281  m_peakLevel = 0.0f;
282  m_levelSum = 0.0f;
283  m_levelCalcCount = 0;
284  }
285 }
static const int m_levelNbSamples
Definition: wfmmod.h:317
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
quint32 m_levelCalcCount
Definition: wfmmod.h:309
Real m_peakLevel
Definition: wfmmod.h:310
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2283
Real m_levelSum
Definition: wfmmod.h:311
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:

◆ deserialize()

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

Implements ChannelAPI.

Definition at line 586 of file wfmmod.cpp.

References WFMMod::MsgConfigureWFMMod::create(), WFMModSettings::deserialize(), BasebandSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and WFMModSettings::resetToDefaults().

Referenced by getCenterFrequency().

587 {
588  if (m_settings.deserialize(data))
589  {
590  MsgConfigureWFMMod *msg = MsgConfigureWFMMod::create(m_settings, true);
592  return true;
593  }
594  else
595  {
597  MsgConfigureWFMMod *msg = MsgConfigureWFMMod::create(m_settings, true);
599  return false;
600  }
601 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigureWFMMod * create(const WFMModSettings &settings, bool force)
Definition: wfmmod.h:59
bool deserialize(const QByteArray &data)
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
WFMModSettings m_settings
Definition: wfmmod.h:276
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

virtual void WFMMod::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 207 of file wfmmod.h.

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

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

◆ getCenterFrequency()

virtual qint64 WFMMod::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 217 of file wfmmod.h.

References deserialize(), WFMModSettings::m_inputFrequencyOffset, WFMMod::MsgConfigureWFMMod::m_settings, and serialize().

WFMModSettings m_settings
Definition: wfmmod.h:276
qint64 m_inputFrequencyOffset
+ Here is the call graph for this function:

◆ getCWKeyer()

CWKeyer* WFMMod::getCWKeyer ( )
inline

Definition at line 248 of file wfmmod.h.

References m_cwKeyer.

Referenced by WFMModGUI::WFMModGUI().

248 { return &m_cwKeyer; }
CWKeyer m_cwKeyer
Definition: wfmmod.h:312
+ Here is the caller graph for this function:

◆ getIdentifier()

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

Implements ChannelAPI.

Definition at line 215 of file wfmmod.h.

215 { id = objectName(); }

◆ getMagSq()

double WFMMod::getMagSq ( ) const
inline

Definition at line 246 of file wfmmod.h.

References m_magsq.

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

246 { return m_magsq; }
double m_magsq
Definition: wfmmod.h:292
+ Here is the caller graph for this function:

◆ getNbSinkStreams()

virtual int WFMMod::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 222 of file wfmmod.h.

222 { return 1; }

◆ getNbSourceStreams()

virtual int WFMMod::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 223 of file wfmmod.h.

223 { return 0; }

◆ getStreamCenterFrequency()

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

Implements ChannelAPI.

Definition at line 225 of file wfmmod.h.

References WFMModSettings::m_inputFrequencyOffset, WFMMod::MsgConfigureWFMMod::m_settings, webapiReportGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

226  {
227  (void) streamIndex;
228  (void) sinkElseSource;
230  }
WFMModSettings m_settings
Definition: wfmmod.h:276
qint64 m_inputFrequencyOffset
+ Here is the call graph for this function:

◆ getTitle()

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

Implements ChannelAPI.

Definition at line 216 of file wfmmod.h.

References WFMMod::MsgConfigureWFMMod::m_settings, and WFMModSettings::m_title.

216 { title = m_settings.m_title; }
WFMModSettings m_settings
Definition: wfmmod.h:276

◆ handleMessage()

bool WFMMod::handleMessage ( const Message cmd)
virtual

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

Implements BasebandSampleSource.

Definition at line 300 of file wfmmod.cpp.

References applyAudioSampleRate(), applyChannelSettings(), applySettings(), UpChannelizer::configure(), WFMMod::MsgReportFileSourceStreamTiming::create(), UpChannelizer::MsgChannelizerNotification::getBasebandSampleRate(), WFMMod::MsgConfigureChannelizer::getCenterFrequency(), WFMMod::MsgConfigureFileSourceName::getFileName(), WFMMod::MsgConfigureWFMMod::getForce(), UpChannelizer::MsgChannelizerNotification::getFrequencyOffset(), BasebandSampleSource::getInputMessageQueue(), BasebandSampleSource::getMessageQueueToGUI(), WFMMod::MsgConfigureFileSourceSeek::getPercentage(), UpChannelizer::MsgChannelizerNotification::getSampleRate(), WFMMod::MsgConfigureChannelizer::getSampleRate(), DSPConfigureAudio::getSampleRate(), WFMMod::MsgConfigureWFMMod::getSettings(), CWKeyer::MsgConfigureCWKeyer::getSettings(), m_audioSampleRate, m_channelizer, m_fileName, m_fileSize, m_ifstream, m_settings, WFMModSettings::m_useReverseAPI, Message::match(), openFileStream(), MessageQueue::push(), seekFileStream(), and webapiReverseSendCWSettings().

Referenced by destroy().

301 {
303  {
305  qDebug() << "WFMMod::handleMessage: MsgChannelizerNotification";
306 
308 
309  return true;
310  }
311  else if (MsgConfigureChannelizer::match(cmd))
312  {
313  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
314  qDebug() << "WFMMod::handleMessage: MsgConfigureChannelizer:"
315  << " getSampleRate: " << cfg.getSampleRate()
316  << " getCenterFrequency: " << cfg.getCenterFrequency();
317 
319  cfg.getSampleRate(),
320  cfg.getCenterFrequency());
321 
322  return true;
323  }
324  else if (MsgConfigureWFMMod::match(cmd))
325  {
326  MsgConfigureWFMMod& cfg = (MsgConfigureWFMMod&) cmd;
327  qDebug() << "NFWFMMod::handleMessage: MsgConfigureWFMMod";
328 
329  WFMModSettings settings = cfg.getSettings();
330 
331  applySettings(cfg.getSettings(), cfg.getForce());
332 
333  return true;
334  }
335  else if (MsgConfigureFileSourceName::match(cmd))
336  {
337  MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) cmd;
338  m_fileName = conf.getFileName();
339  openFileStream();
340  return true;
341  }
342  else if (MsgConfigureFileSourceSeek::match(cmd))
343  {
344  MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) cmd;
345  int seekPercentage = conf.getPercentage();
346  seekFileStream(seekPercentage);
347 
348  return true;
349  }
351  {
352  std::size_t samplesCount;
353 
354  if (m_ifstream.eof()) {
355  samplesCount = m_fileSize / sizeof(Real);
356  } else {
357  samplesCount = m_ifstream.tellg() / sizeof(Real);
358  }
359 
360  MsgReportFileSourceStreamTiming *report;
361  report = MsgReportFileSourceStreamTiming::create(samplesCount);
362  getMessageQueueToGUI()->push(report);
363 
364  return true;
365  }
367  {
369 
372  }
373 
374  return true;
375  }
376  else if (DSPConfigureAudio::match(cmd))
377  {
378  DSPConfigureAudio& cfg = (DSPConfigureAudio&) cmd;
379  uint32_t sampleRate = cfg.getSampleRate();
380 
381  qDebug() << "WFMMod::handleMessage: DSPConfigureAudio:"
382  << " sampleRate: " << sampleRate;
383 
384  if (sampleRate != m_audioSampleRate) {
385  applyAudioSampleRate(sampleRate);
386  }
387 
388  return true;
389  }
390  else if (DSPSignalNotification::match(cmd))
391  {
392  return true;
393  }
394  else
395  {
396  return false;
397  }
398 }
UpChannelizer * m_channelizer
Definition: wfmmod.h:271
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: wfmmod.cpp:449
void seekFileStream(int seekPercentage)
Definition: wfmmod.cpp:422
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
QString m_fileName
Definition: wfmmod.h:304
unsigned int uint32_t
Definition: rtptypes_win.h:46
quint64 m_fileSize
raw file size (bytes)
Definition: wfmmod.h:305
void openFileStream()
Definition: wfmmod.cpp:400
int getSampleRate() const
Definition: dspcommands.h:390
static MsgReportFileSourceStreamTiming * create(std::size_t samplesCount)
Definition: wfmmod.h:164
static bool match(const Message *message)
Definition: message.cpp:45
quint32 m_audioSampleRate
Definition: wfmmod.h:295
void applySettings(const WFMModSettings &settings, bool force=false)
Definition: wfmmod.cpp:485
std::ifstream m_ifstream
Definition: wfmmod.h:303
MessageQueue * getMessageQueueToGUI()
void applyAudioSampleRate(int sampleRate)
Definition: wfmmod.cpp:435
WFMModSettings m_settings
Definition: wfmmod.h:276
void webapiReverseSendCWSettings(const CWKeyerSettings &settings)
Definition: wfmmod.cpp:854
float Real
Definition: dsptypes.h:42
const CWKeyerSettings & getSettings() const
Definition: cwkeyer.h:60
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ levelChanged

void WFMMod::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:

◆ networkManagerFinished

void WFMMod::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 885 of file wfmmod.cpp.

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

886 {
887  QNetworkReply::NetworkError replyError = reply->error();
888 
889  if (replyError)
890  {
891  qWarning() << "WFMMod::networkManagerFinished:"
892  << " error(" << (int) replyError
893  << "): " << replyError
894  << ": " << reply->errorString();
895  return;
896  }
897 
898  QString answer = reply->readAll();
899  answer.chop(1); // remove last \n
900  qDebug("WFMMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
901 }
+ Here is the caller graph for this function:

◆ openFileStream()

void WFMMod::openFileStream ( )
private

Definition at line 400 of file wfmmod.cpp.

References WFMMod::MsgReportFileSourceStreamData::create(), BasebandSampleSource::getMessageQueueToGUI(), m_fileName, m_fileSize, m_ifstream, m_recordLength, m_sampleRate, and MessageQueue::push().

Referenced by handleMessage().

401 {
402  if (m_ifstream.is_open()) {
403  m_ifstream.close();
404  }
405 
406  m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
407  m_fileSize = m_ifstream.tellg();
408  m_ifstream.seekg(0,std::ios_base::beg);
409 
410  m_sampleRate = 48000; // fixed rate
411  m_recordLength = m_fileSize / (sizeof(Real) * m_sampleRate);
412 
413  qDebug() << "WFMMod::openFileStream: " << m_fileName.toStdString().c_str()
414  << " fileSize: " << m_fileSize << "bytes"
415  << " length: " << m_recordLength << " seconds";
416 
417  MsgReportFileSourceStreamData *report;
418  report = MsgReportFileSourceStreamData::create(m_sampleRate, m_recordLength);
419  getMessageQueueToGUI()->push(report);
420 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
int m_sampleRate
Definition: wfmmod.h:307
static MsgReportFileSourceStreamData * create(int sampleRate, quint32 recordLength)
Definition: wfmmod.h:185
QString m_fileName
Definition: wfmmod.h:304
quint64 m_fileSize
raw file size (bytes)
Definition: wfmmod.h:305
std::ifstream m_ifstream
Definition: wfmmod.h:303
MessageQueue * getMessageQueueToGUI()
quint32 m_recordLength
record length in seconds computed from file size
Definition: wfmmod.h:306
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pull()

void WFMMod::pull ( Sample sample)
virtual

Implements BasebandSampleSource.

Definition at line 116 of file wfmmod.cpp.

References MovingAverageUtil< T, Total, N >::asDouble(), calculateLevel(), cos(), Interpolator::interpolate(), m_audioBufferFill, m_carrierNco, WFMModSettings::m_channelMute, WFMModSettings::m_fmDeviation, Sample::m_imag, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_magsq, WFMModSettings::m_modAFInput, m_modPhasor, m_modSample, m_movingAverage, m_outputSampleRate, M_PI, Sample::m_real, m_rfFilter, m_rfFilterBuffer, m_rfFilterBufferIndex, m_settings, m_settingsMutex, NCO::nextIQ(), pullAF(), fftfilt::runFilt(), SDR_TX_SCALED, SDR_TX_SCALEF, sin(), WFMModSettings::WFMModInputAudio, and WFMModSettings::WFMModInputFile.

Referenced by destroy().

117 {
119  {
120  sample.m_real = 0.0f;
121  sample.m_imag = 0.0f;
122  return;
123  }
124 
125  Complex ci, ri;
126  fftfilt::cmplx *rf;
127  int rf_out;
128 
129  m_settingsMutex.lock();
130 
133  {
135  {
137  calculateLevel(m_modSample.real());
139  }
140 
142  }
143  else
144  {
145  pullAF(ri);
146  }
147 
148  m_modPhasor += (m_settings.m_fmDeviation / (float) m_outputSampleRate) * ri.real() * M_PI * 2.0f;
149  ci.real(cos(m_modPhasor) * 0.891235351562f * SDR_TX_SCALEF); // -1 dB
150  ci.imag(sin(m_modPhasor) * 0.891235351562f * SDR_TX_SCALEF);
151 
152  // RF filtering
153  rf_out = m_rfFilter->runFilt(ci, &rf);
154 
155  if (rf_out > 0)
156  {
157  memcpy((void *) m_rfFilterBuffer, (const void *) rf, rf_out*sizeof(Complex));
159 
160  }
161 
162  ci = m_rfFilterBuffer[m_rfFilterBufferIndex] * m_carrierNco.nextIQ(); // shift to carrier frequency
164 
165  m_settingsMutex.unlock();
166 
167  double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
168  magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
169  m_movingAverage(magsq);
171 
172  sample.m_real = (FixReal) ci.real();
173  sample.m_imag = (FixReal) ci.imag();
174 }
double m_magsq
Definition: wfmmod.h:292
Complex nextIQ()
Return next complex sample.
Definition: nco.cpp:61
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
bool interpolate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:53
fftfilt::cmplx * m_rfFilterBuffer
Definition: wfmmod.h:289
Complex m_modSample
Definition: wfmmod.h:281
fftfilt * m_rfFilter
Definition: wfmmod.h:287
void calculateLevel(const Real &sample)
Definition: wfmmod.cpp:268
int runFilt(const cmplx &in, cmplx **out)
Definition: fftfilt.cpp:260
Real m_interpolatorDistance
Definition: wfmmod.h:283
WFMModInputAF m_modAFInput
void pullAF(Complex &sample)
Definition: wfmmod.cpp:189
#define M_PI
Definition: rdsdemod.cpp:27
std::complex< float > cmplx
Definition: fftfilt.h:21
#define SDR_TX_SCALEF
Definition: dsptypes.h:39
int m_rfFilterBufferIndex
Definition: wfmmod.h:290
FixReal m_real
Definition: dsptypes.h:64
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2265
MovingAverageUtil< double, double, 16 > m_movingAverage
Definition: wfmmod.h:293
Real m_interpolatorDistanceRemain
Definition: wfmmod.h:284
FixReal m_imag
Definition: dsptypes.h:65
WFMModSettings m_settings
Definition: wfmmod.h:276
int m_outputSampleRate
Definition: wfmmod.h:274
Interpolator m_interpolator
Definition: wfmmod.h:282
std::complex< Real > Complex
Definition: dsptypes.h:43
double asDouble() const
Definition: movingaverage.h:57
float m_modPhasor
baseband modulator phasor
Definition: wfmmod.h:280
#define SDR_TX_SCALED
Definition: dsptypes.h:40
NCO m_carrierNco
Definition: wfmmod.h:278
QMutex m_settingsMutex
Definition: wfmmod.h:301
qint16 FixReal
Definition: dsptypes.h:35
uint m_audioBufferFill
Definition: wfmmod.h:297
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pullAF()

void WFMMod::pullAF ( Complex sample)
private

Definition at line 189 of file wfmmod.cpp.

References CWKeyer::getCWSmoother(), CWSmoother::getFadeSample(), CWKeyer::getSample(), m_audioBuffer, m_audioBufferFill, m_cwKeyer, m_ifstream, WFMModSettings::m_modAFInput, WFMModSettings::m_playLoop, m_settings, m_toneNcoRF, WFMModSettings::m_volumeFactor, NCOF::next(), NCOF::setPhase(), WFMModSettings::WFMModInputAudio, WFMModSettings::WFMModInputCWTone, WFMModSettings::WFMModInputFile, WFMModSettings::WFMModInputNone, and WFMModSettings::WFMModInputTone.

Referenced by pull().

190 {
191  switch (m_settings.m_modAFInput)
192  {
194  sample.real(m_toneNcoRF.next() * m_settings.m_volumeFactor);
195  sample.imag(0.0f);
196  break;
198  // sox f4exb_call.wav --encoding float --endian little f4exb_call.raw
199  // ffplay -f f32le -ar 48k -ac 1 f4exb_call.raw
200  if (m_ifstream.is_open())
201  {
202  if (m_ifstream.eof())
203  {
205  {
206  m_ifstream.clear();
207  m_ifstream.seekg(0, std::ios::beg);
208  }
209  }
210 
211  if (m_ifstream.eof())
212  {
213  sample.real(0.0f);
214  sample.imag(0.0f);
215  }
216  else
217  {
218  Real s;
219  m_ifstream.read(reinterpret_cast<char*>(&s), sizeof(Real));
220  sample.real(s * m_settings.m_volumeFactor);
221  sample.imag(0.0f);
222  }
223  }
224  else
225  {
226  sample.real(0.0f);
227  sample.imag(0.0f);
228  }
229  break;
231  {
233  sample.imag(0.0f);
234  }
235  break;
237  Real fadeFactor;
238 
239  if (m_cwKeyer.getSample())
240  {
241  m_cwKeyer.getCWSmoother().getFadeSample(true, fadeFactor);
242  sample.real(m_toneNcoRF.next() * m_settings.m_volumeFactor * fadeFactor);
243  sample.imag(0.0f);
244  }
245  else
246  {
247  if (m_cwKeyer.getCWSmoother().getFadeSample(false, fadeFactor))
248  {
249  sample.real(m_toneNcoRF.next() * m_settings.m_volumeFactor * fadeFactor);
250  sample.imag(0.0f);
251  }
252  else
253  {
254  sample.real(0.0f);
255  sample.imag(0.0f);
257  }
258  }
259  break;
261  default:
262  sample.real(0.0f);
263  sample.imag(0.0f);
264  break;
265  }
266 }
CWKeyer m_cwKeyer
Definition: wfmmod.h:312
NCOF m_toneNcoRF
Definition: wfmmod.h:279
WFMModInputAF m_modAFInput
AudioVector m_audioBuffer
Definition: wfmmod.h:296
void setPhase(Real phase)
Definition: ncof.h:42
bool getFadeSample(bool on, float &sample)
Definition: cwkeyer.cpp:487
CWSmoother & getCWSmoother()
Definition: cwkeyer.h:111
int getSample()
Definition: cwkeyer.cpp:194
std::ifstream m_ifstream
Definition: wfmmod.h:303
WFMModSettings m_settings
Definition: wfmmod.h:276
Real next()
Return next real sample.
Definition: ncof.cpp:57
float Real
Definition: dsptypes.h:42
uint m_audioBufferFill
Definition: wfmmod.h:297
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pullAudio()

void WFMMod::pullAudio ( int  nbSamples)
virtual

Reimplemented from BasebandSampleSource.

Definition at line 176 of file wfmmod.cpp.

References m_audioBuffer, m_audioBufferFill, m_audioFifo, m_audioSampleRate, m_basebandSampleRate, and AudioFifo::read().

Referenced by destroy().

177 {
178  unsigned int nbSamplesAudio = nbSamples * ((Real) m_audioSampleRate / (Real) m_basebandSampleRate);
179 
180  if (nbSamplesAudio > m_audioBuffer.size())
181  {
182  m_audioBuffer.resize(nbSamplesAudio);
183  }
184 
185  m_audioFifo.read(reinterpret_cast<quint8*>(&m_audioBuffer[0]), nbSamplesAudio);
186  m_audioBufferFill = 0;
187 }
AudioVector m_audioBuffer
Definition: wfmmod.h:296
quint32 m_audioSampleRate
Definition: wfmmod.h:295
uint32_t read(quint8 *data, uint32_t numSamples)
Definition: audiofifo.cpp:103
AudioFifo m_audioFifo
Definition: wfmmod.h:298
int m_basebandSampleRate
Definition: wfmmod.h:273
float Real
Definition: dsptypes.h:42
uint m_audioBufferFill
Definition: wfmmod.h:297
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ seekFileStream()

void WFMMod::seekFileStream ( int  seekPercentage)
private

Definition at line 422 of file wfmmod.cpp.

References m_ifstream, m_recordLength, m_sampleRate, and m_settingsMutex.

Referenced by handleMessage().

423 {
424  QMutexLocker mutexLocker(&m_settingsMutex);
425 
426  if (m_ifstream.is_open())
427  {
428  int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
429  seekPoint *= sizeof(Real);
430  m_ifstream.clear();
431  m_ifstream.seekg(seekPoint, std::ios::beg);
432  }
433 }
int m_sampleRate
Definition: wfmmod.h:307
std::ifstream m_ifstream
Definition: wfmmod.h:303
quint32 m_recordLength
record length in seconds computed from file size
Definition: wfmmod.h:306
float Real
Definition: dsptypes.h:42
QMutex m_settingsMutex
Definition: wfmmod.h:301
+ Here is the caller graph for this function:

◆ serialize()

QByteArray WFMMod::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 581 of file wfmmod.cpp.

References m_settings, and WFMModSettings::serialize().

Referenced by getCenterFrequency().

582 {
583  return m_settings.serialize();
584 }
QByteArray serialize() const
WFMModSettings m_settings
Definition: wfmmod.h:276
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

void WFMMod::start ( )
virtual

Implements BasebandSampleSource.

Definition at line 287 of file wfmmod.cpp.

References applyChannelSettings(), AudioFifo::clear(), m_audioFifo, m_basebandSampleRate, m_inputFrequencyOffset, and m_outputSampleRate.

Referenced by destroy().

288 {
289  qDebug() << "WFMMod::start: m_outputSampleRate: " << m_outputSampleRate
290  << " m_inputFrequencyOffset: " << m_inputFrequencyOffset;
291 
292  m_audioFifo.clear();
293  applyChannelSettings(m_basebandSampleRate, m_outputSampleRate, m_inputFrequencyOffset, true);
294 }
void clear()
Definition: audiofifo.cpp:156
void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: wfmmod.cpp:449
AudioFifo m_audioFifo
Definition: wfmmod.h:298
int m_basebandSampleRate
Definition: wfmmod.h:273
int m_outputSampleRate
Definition: wfmmod.h:274
int m_inputFrequencyOffset
Definition: wfmmod.h:275
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void WFMMod::stop ( )
virtual

Implements BasebandSampleSource.

Definition at line 296 of file wfmmod.cpp.

Referenced by destroy().

297 {
298 }
+ Here is the caller graph for this function:

◆ webapiFormatChannelReport()

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

Definition at line 771 of file wfmmod.cpp.

References CalcDb::dbPower(), getMagSq(), SWGSDRangel::SWGChannelReport::getWfmModReport(), m_audioSampleRate, m_outputSampleRate, SWGSDRangel::SWGWFMModReport::setAudioSampleRate(), SWGSDRangel::SWGWFMModReport::setChannelPowerDb(), and SWGSDRangel::SWGWFMModReport::setChannelSampleRate().

Referenced by webapiReportGet().

772 {
776 }
static double dbPower(double magsq, double floor=1e-12)
Definition: db.cpp:22
double getMagSq() const
Definition: wfmmod.h:246
void setChannelPowerDb(float channel_power_db)
quint32 m_audioSampleRate
Definition: wfmmod.h:295
SWGWFMModReport * getWfmModReport()
void setChannelSampleRate(qint32 channel_sample_rate)
void setAudioSampleRate(qint32 audio_sample_rate)
int m_outputSampleRate
Definition: wfmmod.h:274
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatChannelSettings()

void WFMMod::webapiFormatChannelSettings ( SWGSDRangel::SWGChannelSettings response,
const WFMModSettings settings 
)
private

Definition at line 724 of file wfmmod.cpp.

References SWGSDRangel::SWGWFMModSettings::getAudioDeviceName(), SWGSDRangel::SWGWFMModSettings::getCwKeyer(), SWGSDRangel::SWGWFMModSettings::getReverseApiAddress(), CWKeyer::getSettings(), SWGSDRangel::SWGWFMModSettings::getTitle(), SWGSDRangel::SWGChannelSettings::getWfmModSettings(), WFMModSettings::m_afBandwidth, WFMModSettings::m_audioDeviceName, WFMModSettings::m_channelMute, m_cwKeyer, WFMModSettings::m_fmDeviation, WFMModSettings::m_inputFrequencyOffset, WFMModSettings::m_modAFInput, WFMModSettings::m_playLoop, WFMModSettings::m_reverseAPIAddress, WFMModSettings::m_reverseAPIChannelIndex, WFMModSettings::m_reverseAPIDeviceIndex, WFMModSettings::m_reverseAPIPort, WFMModSettings::m_rfBandwidth, WFMModSettings::m_rgbColor, WFMModSettings::m_title, WFMModSettings::m_toneFrequency, WFMModSettings::m_useReverseAPI, WFMModSettings::m_volumeFactor, SWGSDRangel::SWGWFMModSettings::setAfBandwidth(), SWGSDRangel::SWGWFMModSettings::setAudioDeviceName(), SWGSDRangel::SWGWFMModSettings::setChannelMute(), SWGSDRangel::SWGWFMModSettings::setCwKeyer(), SWGSDRangel::SWGWFMModSettings::setFmDeviation(), SWGSDRangel::SWGWFMModSettings::setInputFrequencyOffset(), SWGSDRangel::SWGWFMModSettings::setModAfInput(), SWGSDRangel::SWGWFMModSettings::setPlayLoop(), SWGSDRangel::SWGWFMModSettings::setReverseApiAddress(), SWGSDRangel::SWGWFMModSettings::setReverseApiChannelIndex(), SWGSDRangel::SWGWFMModSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGWFMModSettings::setReverseApiPort(), SWGSDRangel::SWGWFMModSettings::setRfBandwidth(), SWGSDRangel::SWGWFMModSettings::setRgbColor(), SWGSDRangel::SWGWFMModSettings::setTitle(), SWGSDRangel::SWGWFMModSettings::setToneFrequency(), SWGSDRangel::SWGWFMModSettings::setUseReverseApi(), SWGSDRangel::SWGWFMModSettings::setVolumeFactor(), and CWKeyer::webapiFormatChannelSettings().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

725 {
726  response.getWfmModSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
728  response.getWfmModSettings()->setModAfInput((int) settings.m_modAFInput);
729  response.getWfmModSettings()->setPlayLoop(settings.m_playLoop ? 1 : 0);
730  response.getWfmModSettings()->setRfBandwidth(settings.m_rfBandwidth);
731  response.getWfmModSettings()->setAfBandwidth(settings.m_afBandwidth);
732  response.getWfmModSettings()->setFmDeviation(settings.m_fmDeviation);
733  response.getWfmModSettings()->setRgbColor(settings.m_rgbColor);
734 
735  if (response.getWfmModSettings()->getTitle()) {
736  *response.getWfmModSettings()->getTitle() = settings.m_title;
737  } else {
738  response.getWfmModSettings()->setTitle(new QString(settings.m_title));
739  }
740 
741  response.getWfmModSettings()->setToneFrequency(settings.m_toneFrequency);
742  response.getWfmModSettings()->setVolumeFactor(settings.m_volumeFactor);
743 
744  if (!response.getWfmModSettings()->getCwKeyer()) {
746  }
747 
748  SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getWfmModSettings()->getCwKeyer();
749  const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings();
750  m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
751 
752  if (response.getWfmModSettings()->getAudioDeviceName()) {
753  *response.getWfmModSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
754  } else {
755  response.getWfmModSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
756  }
757 
758  response.getWfmModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
759 
760  if (response.getWfmModSettings()->getReverseApiAddress()) {
762  } else {
763  response.getWfmModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
764  }
765 
769 }
CWKeyer m_cwKeyer
Definition: wfmmod.h:312
uint16_t m_reverseAPIChannelIndex
void setRfBandwidth(float rf_bandwidth)
WFMModInputAF m_modAFInput
void setChannelMute(qint32 channel_mute)
quint32 m_rgbColor
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setUseReverseApi(qint32 use_reverse_api)
SWGCWKeyerSettings * getCwKeyer()
void setReverseApiPort(qint32 reverse_api_port)
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setPlayLoop(qint32 play_loop)
void setAudioDeviceName(QString *audio_device_name)
QString m_audioDeviceName
This is the audio device you get the audio samples from.
void setCwKeyer(SWGCWKeyerSettings *cw_keyer)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
static void webapiFormatChannelSettings(SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings, const CWKeyerSettings &cwKeyerSettings)
Definition: cwkeyer.cpp:637
SWGWFMModSettings * getWfmModSettings()
void setReverseApiAddress(QString *reverse_api_address)
uint16_t m_reverseAPIPort
void setFmDeviation(float fm_deviation)
QString m_reverseAPIAddress
void setAfBandwidth(float af_bandwidth)
const CWKeyerSettings & getSettings() const
Definition: cwkeyer.h:107
void setToneFrequency(float tone_frequency)
void setModAfInput(qint32 mod_af_input)
qint64 m_inputFrequencyOffset
uint16_t m_reverseAPIDeviceIndex
void setVolumeFactor(float volume_factor)
void setRgbColor(qint32 rgb_color)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from ChannelAPI.

Definition at line 713 of file wfmmod.cpp.

References SWGSDRangel::SWGChannelReport::getWfmModReport(), SWGSDRangel::SWGWFMModReport::init(), SWGSDRangel::SWGChannelReport::setWfmModReport(), and webapiFormatChannelReport().

Referenced by getStreamCenterFrequency().

716 {
717  (void) errorMessage;
719  response.getWfmModReport()->init();
720  webapiFormatChannelReport(response);
721  return 200;
722 }
void setWfmModReport(SWGWFMModReport *wfm_mod_report)
SWGWFMModReport * getWfmModReport()
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
Definition: wfmmod.cpp:771
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendCWSettings()

void WFMMod::webapiReverseSendCWSettings ( const CWKeyerSettings settings)
private

Definition at line 854 of file wfmmod.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), SWGSDRangel::SWGWFMModSettings::getCwKeyer(), SWGSDRangel::SWGChannelSettings::getWfmModSettings(), m_cwKeyer, m_networkManager, m_networkRequest, WFMModSettings::m_reverseAPIAddress, WFMModSettings::m_reverseAPIChannelIndex, WFMModSettings::m_reverseAPIDeviceIndex, WFMModSettings::m_reverseAPIPort, m_settings, SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGWFMModSettings::setCwKeyer(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGChannelSettings::setWfmModSettings(), and CWKeyer::webapiFormatChannelSettings().

Referenced by handleMessage().

855 {
857  swgChannelSettings->setDirection(1); // single source (Tx)
858  swgChannelSettings->setChannelType(new QString("WFMMod"));
859  swgChannelSettings->setWfmModSettings(new SWGSDRangel::SWGWFMModSettings());
860  SWGSDRangel::SWGWFMModSettings *swgWFMModSettings = swgChannelSettings->getWfmModSettings();
861 
862  swgWFMModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings());
863  SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgWFMModSettings->getCwKeyer();
864  m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
865 
866  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
871  m_networkRequest.setUrl(QUrl(channelSettingsURL));
872  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
873 
874  QBuffer *buffer=new QBuffer();
875  buffer->open((QBuffer::ReadWrite));
876  buffer->write(swgChannelSettings->asJson().toUtf8());
877  buffer->seek(0);
878 
879  // Always use PATCH to avoid passing reverse API settings
880  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
881 
882  delete swgChannelSettings;
883 }
CWKeyer m_cwKeyer
Definition: wfmmod.h:312
uint16_t m_reverseAPIChannelIndex
QNetworkAccessManager * m_networkManager
Definition: wfmmod.h:314
void setWfmModSettings(SWGWFMModSettings *wfm_mod_settings)
void setChannelType(QString *channel_type)
SWGCWKeyerSettings * getCwKeyer()
QNetworkRequest m_networkRequest
Definition: wfmmod.h:315
void setCwKeyer(SWGCWKeyerSettings *cw_keyer)
virtual QString asJson() override
static void webapiFormatChannelSettings(SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings, const CWKeyerSettings &cwKeyerSettings)
Definition: cwkeyer.cpp:637
SWGWFMModSettings * getWfmModSettings()
uint16_t m_reverseAPIPort
QString m_reverseAPIAddress
WFMModSettings m_settings
Definition: wfmmod.h:276
uint16_t m_reverseAPIDeviceIndex
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 778 of file wfmmod.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), SWGSDRangel::SWGWFMModSettings::getCwKeyer(), ChannelAPI::getDeviceSetIndex(), ChannelAPI::getIndexInDeviceSet(), CWKeyer::getSettings(), SWGSDRangel::SWGChannelSettings::getWfmModSettings(), WFMModSettings::m_afBandwidth, WFMModSettings::m_audioDeviceName, WFMModSettings::m_channelMute, m_cwKeyer, WFMModSettings::m_fmDeviation, WFMModSettings::m_inputFrequencyOffset, WFMModSettings::m_modAFInput, m_networkManager, m_networkRequest, WFMModSettings::m_playLoop, WFMModSettings::m_reverseAPIAddress, WFMModSettings::m_reverseAPIChannelIndex, WFMModSettings::m_reverseAPIDeviceIndex, WFMModSettings::m_reverseAPIPort, WFMModSettings::m_rfBandwidth, WFMModSettings::m_rgbColor, WFMModSettings::m_title, WFMModSettings::m_toneFrequency, WFMModSettings::m_volumeFactor, SWGSDRangel::SWGWFMModSettings::setAfBandwidth(), SWGSDRangel::SWGWFMModSettings::setAudioDeviceName(), SWGSDRangel::SWGWFMModSettings::setChannelMute(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGWFMModSettings::setCwKeyer(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGWFMModSettings::setFmDeviation(), SWGSDRangel::SWGWFMModSettings::setInputFrequencyOffset(), SWGSDRangel::SWGWFMModSettings::setModAfInput(), SWGSDRangel::SWGChannelSettings::setOriginatorChannelIndex(), SWGSDRangel::SWGChannelSettings::setOriginatorDeviceSetIndex(), SWGSDRangel::SWGWFMModSettings::setPlayLoop(), SWGSDRangel::SWGWFMModSettings::setRfBandwidth(), SWGSDRangel::SWGWFMModSettings::setRgbColor(), SWGSDRangel::SWGWFMModSettings::setTitle(), SWGSDRangel::SWGWFMModSettings::setToneFrequency(), SWGSDRangel::SWGWFMModSettings::setVolumeFactor(), SWGSDRangel::SWGChannelSettings::setWfmModSettings(), and CWKeyer::webapiFormatChannelSettings().

Referenced by applySettings().

779 {
781  swgChannelSettings->setDirection(1); // single source (Tx)
782  swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
783  swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
784  swgChannelSettings->setChannelType(new QString("WFMMod"));
785  swgChannelSettings->setWfmModSettings(new SWGSDRangel::SWGWFMModSettings());
786  SWGSDRangel::SWGWFMModSettings *swgWFMModSettings = swgChannelSettings->getWfmModSettings();
787 
788  // transfer data that has been modified. When force is on transfer all data except reverse API data
789 
790  if (channelSettingsKeys.contains("channelMute") || force) {
791  swgWFMModSettings->setChannelMute(settings.m_channelMute ? 1 : 0);
792  }
793  if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
794  swgWFMModSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
795  }
796  if (channelSettingsKeys.contains("modAFInput") || force) {
797  swgWFMModSettings->setModAfInput((int) settings.m_modAFInput);
798  }
799  if (channelSettingsKeys.contains("playLoop") || force) {
800  swgWFMModSettings->setPlayLoop(settings.m_playLoop ? 1 : 0);
801  }
802  if (channelSettingsKeys.contains("rfBandwidth") || force) {
803  swgWFMModSettings->setRfBandwidth(settings.m_rfBandwidth);
804  }
805  if (channelSettingsKeys.contains("afBandwidth") || force) {
806  swgWFMModSettings->setAfBandwidth(settings.m_afBandwidth);
807  }
808  if (channelSettingsKeys.contains("rgbColor") || force) {
809  swgWFMModSettings->setRgbColor(settings.m_rgbColor);
810  }
811  if (channelSettingsKeys.contains("title") || force) {
812  swgWFMModSettings->setTitle(new QString(settings.m_title));
813  }
814  if (channelSettingsKeys.contains("toneFrequency") || force) {
815  swgWFMModSettings->setToneFrequency(settings.m_toneFrequency);
816  }
817  if (channelSettingsKeys.contains("volumeFactor") || force) {
818  swgWFMModSettings->setVolumeFactor(settings.m_volumeFactor);
819  }
820  if (channelSettingsKeys.contains("fmDeviation")) {
821  swgWFMModSettings->setFmDeviation(settings.m_fmDeviation);
822  }
823  if (channelSettingsKeys.contains("audioDeviceName") || force) {
824  swgWFMModSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
825  }
826 
827  if (force)
828  {
829  const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings();
830  swgWFMModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings());
831  SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgWFMModSettings->getCwKeyer();
832  m_cwKeyer.webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
833  }
834 
835  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
836  .arg(settings.m_reverseAPIAddress)
837  .arg(settings.m_reverseAPIPort)
838  .arg(settings.m_reverseAPIDeviceIndex)
839  .arg(settings.m_reverseAPIChannelIndex);
840  m_networkRequest.setUrl(QUrl(channelSettingsURL));
841  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
842 
843  QBuffer *buffer=new QBuffer();
844  buffer->open((QBuffer::ReadWrite));
845  buffer->write(swgChannelSettings->asJson().toUtf8());
846  buffer->seek(0);
847 
848  // Always use PATCH to avoid passing reverse API settings
849  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
850 
851  delete swgChannelSettings;
852 }
void setOriginatorChannelIndex(qint32 originator_channel_index)
CWKeyer m_cwKeyer
Definition: wfmmod.h:312
uint16_t m_reverseAPIChannelIndex
QNetworkAccessManager * m_networkManager
Definition: wfmmod.h:314
void setRfBandwidth(float rf_bandwidth)
int getDeviceSetIndex() const
Definition: channelapi.h:89
void setWfmModSettings(SWGWFMModSettings *wfm_mod_settings)
WFMModInputAF m_modAFInput
void setChannelType(QString *channel_type)
void setChannelMute(qint32 channel_mute)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
quint32 m_rgbColor
SWGCWKeyerSettings * getCwKeyer()
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setPlayLoop(qint32 play_loop)
QNetworkRequest m_networkRequest
Definition: wfmmod.h:315
void setAudioDeviceName(QString *audio_device_name)
QString m_audioDeviceName
This is the audio device you get the audio samples from.
void setCwKeyer(SWGCWKeyerSettings *cw_keyer)
virtual QString asJson() override
static void webapiFormatChannelSettings(SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings, const CWKeyerSettings &cwKeyerSettings)
Definition: cwkeyer.cpp:637
SWGWFMModSettings * getWfmModSettings()
uint16_t m_reverseAPIPort
void setFmDeviation(float fm_deviation)
QString m_reverseAPIAddress
void setAfBandwidth(float af_bandwidth)
const CWKeyerSettings & getSettings() const
Definition: cwkeyer.h:107
int getIndexInDeviceSet() const
Definition: channelapi.h:87
void setToneFrequency(float tone_frequency)
void setModAfInput(qint32 mod_af_input)
qint64 m_inputFrequencyOffset
uint16_t m_reverseAPIDeviceIndex
void setVolumeFactor(float volume_factor)
void setRgbColor(qint32 rgb_color)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from ChannelAPI.

Definition at line 603 of file wfmmod.cpp.

References SWGSDRangel::SWGChannelSettings::getWfmModSettings(), SWGSDRangel::SWGWFMModSettings::init(), m_settings, SWGSDRangel::SWGChannelSettings::setWfmModSettings(), and webapiFormatChannelSettings().

Referenced by getStreamCenterFrequency().

606 {
607  (void) errorMessage;
609  response.getWfmModSettings()->init();
611  return 200;
612 }
void setWfmModSettings(SWGWFMModSettings *wfm_mod_settings)
SWGWFMModSettings * getWfmModSettings()
WFMModSettings m_settings
Definition: wfmmod.h:276
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const WFMModSettings &settings)
Definition: wfmmod.cpp:724
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from ChannelAPI.

Definition at line 614 of file wfmmod.cpp.

References WFMMod::MsgConfigureWFMMod::create(), CWKeyer::MsgConfigureCWKeyer::create(), WFMMod::MsgConfigureChannelizer::create(), SWGSDRangel::SWGWFMModSettings::getAfBandwidth(), SWGSDRangel::SWGWFMModSettings::getChannelMute(), SWGSDRangel::SWGWFMModSettings::getCwKeyer(), SWGSDRangel::SWGWFMModSettings::getFmDeviation(), SWGSDRangel::SWGWFMModSettings::getInputFrequencyOffset(), CWKeyer::getInputMessageQueue(), SWGSDRangel::SWGWFMModSettings::getModAfInput(), SWGSDRangel::SWGWFMModSettings::getPlayLoop(), SWGSDRangel::SWGWFMModSettings::getReverseApiAddress(), SWGSDRangel::SWGWFMModSettings::getReverseApiChannelIndex(), SWGSDRangel::SWGWFMModSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGWFMModSettings::getReverseApiPort(), SWGSDRangel::SWGWFMModSettings::getRfBandwidth(), SWGSDRangel::SWGWFMModSettings::getRgbColor(), CWKeyer::getSettings(), SWGSDRangel::SWGWFMModSettings::getTitle(), SWGSDRangel::SWGWFMModSettings::getToneFrequency(), SWGSDRangel::SWGWFMModSettings::getUseReverseApi(), SWGSDRangel::SWGWFMModSettings::getVolumeFactor(), SWGSDRangel::SWGChannelSettings::getWfmModSettings(), WFMModSettings::m_afBandwidth, WFMModSettings::m_channelMute, m_cwKeyer, WFMModSettings::m_fmDeviation, BasebandSampleSource::m_guiMessageQueue, WFMModSettings::m_inputFrequencyOffset, BasebandSampleSource::m_inputMessageQueue, WFMModSettings::m_modAFInput, WFMModSettings::m_playLoop, WFMModSettings::m_reverseAPIAddress, WFMModSettings::m_reverseAPIChannelIndex, WFMModSettings::m_reverseAPIDeviceIndex, WFMModSettings::m_reverseAPIPort, WFMModSettings::m_rfBandwidth, WFMModSettings::m_rgbColor, m_settings, WFMModSettings::m_title, WFMModSettings::m_toneFrequency, WFMModSettings::m_useReverseAPI, WFMModSettings::m_volumeFactor, MessageQueue::push(), webapiFormatChannelSettings(), and CWKeyer::webapiSettingsPutPatch().

Referenced by getStreamCenterFrequency().

619 {
620  (void) errorMessage;
621  WFMModSettings settings = m_settings;
622  bool channelizerChange = false;
623 
624  if (channelSettingsKeys.contains("channelMute")) {
625  settings.m_channelMute = response.getWfmModSettings()->getChannelMute() != 0;
626  }
627  if (channelSettingsKeys.contains("inputFrequencyOffset"))
628  {
630  channelizerChange = true;
631  }
632  if (channelSettingsKeys.contains("modAFInput")) {
634  }
635  if (channelSettingsKeys.contains("playLoop")) {
636  settings.m_playLoop = response.getWfmModSettings()->getPlayLoop() != 0;
637  }
638  if (channelSettingsKeys.contains("rfBandwidth")) {
639  settings.m_rfBandwidth = response.getWfmModSettings()->getRfBandwidth();
640  channelizerChange = true;
641  }
642  if (channelSettingsKeys.contains("afBandwidth")) {
643  settings.m_afBandwidth = response.getWfmModSettings()->getAfBandwidth();
644  }
645  if (channelSettingsKeys.contains("rgbColor")) {
646  settings.m_rgbColor = response.getWfmModSettings()->getRgbColor();
647  }
648  if (channelSettingsKeys.contains("title")) {
649  settings.m_title = *response.getWfmModSettings()->getTitle();
650  }
651  if (channelSettingsKeys.contains("toneFrequency")) {
652  settings.m_toneFrequency = response.getWfmModSettings()->getToneFrequency();
653  }
654  if (channelSettingsKeys.contains("volumeFactor")) {
655  settings.m_volumeFactor = response.getWfmModSettings()->getVolumeFactor();
656  }
657  if (channelSettingsKeys.contains("fmDeviation")) {
658  settings.m_fmDeviation = response.getWfmModSettings()->getFmDeviation();
659  }
660  if (channelSettingsKeys.contains("useReverseAPI")) {
661  settings.m_useReverseAPI = response.getWfmModSettings()->getUseReverseApi() != 0;
662  }
663  if (channelSettingsKeys.contains("reverseAPIAddress")) {
665  }
666  if (channelSettingsKeys.contains("reverseAPIPort")) {
667  settings.m_reverseAPIPort = response.getWfmModSettings()->getReverseApiPort();
668  }
669  if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
671  }
672  if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
674  }
675 
676  if (channelSettingsKeys.contains("cwKeyer"))
677  {
678  SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getWfmModSettings()->getCwKeyer();
679  CWKeyerSettings cwKeyerSettings = m_cwKeyer.getSettings();
680  m_cwKeyer.webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings);
681 
682  CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force);
683  m_cwKeyer.getInputMessageQueue()->push(msgCwKeyer);
684 
685  if (m_guiMessageQueue) // forward to GUI if any
686  {
687  CWKeyer::MsgConfigureCWKeyer *msgCwKeyerToGUI = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force);
688  m_guiMessageQueue->push(msgCwKeyerToGUI);
689  }
690  }
691 
692  if (channelizerChange)
693  {
695  settings.m_rfBandwidth, settings.m_inputFrequencyOffset);
696  m_inputMessageQueue.push(msgChan);
697  }
698 
699  MsgConfigureWFMMod *msg = MsgConfigureWFMMod::create(settings, force);
701 
702  if (m_guiMessageQueue) // forward to GUI if any
703  {
704  MsgConfigureWFMMod *msgToGUI = MsgConfigureWFMMod::create(settings, force);
705  m_guiMessageQueue->push(msgToGUI);
706  }
707 
708  webapiFormatChannelSettings(response, settings);
709 
710  return 200;
711 }
CWKeyer m_cwKeyer
Definition: wfmmod.h:312
void push(Message *message, bool emitSignal=true)
Push message onto queue.
uint16_t m_reverseAPIChannelIndex
static MsgConfigureCWKeyer * create(const CWKeyerSettings &settings, bool force)
Definition: cwkeyer.h:63
WFMModInputAF m_modAFInput
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: wfmmod.h:82
quint32 m_rgbColor
static MsgConfigureWFMMod * create(const WFMModSettings &settings, bool force)
Definition: wfmmod.h:59
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
Definition: cwkeyer.h:104
SWGCWKeyerSettings * getCwKeyer()
SWGWFMModSettings * getWfmModSettings()
uint16_t m_reverseAPIPort
static void webapiSettingsPutPatch(const QStringList &channelSettingsKeys, CWKeyerSettings &cwKeyerSettings, SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings)
Definition: cwkeyer.cpp:599
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
QString m_reverseAPIAddress
WFMModSettings m_settings
Definition: wfmmod.h:276
const CWKeyerSettings & getSettings() const
Definition: cwkeyer.h:107
qint64 m_inputFrequencyOffset
uint16_t m_reverseAPIDeviceIndex
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const WFMModSettings &settings)
Definition: wfmmod.cpp:724
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_audioBuffer

AudioVector WFMMod::m_audioBuffer
private

Definition at line 296 of file wfmmod.h.

Referenced by pullAF(), pullAudio(), and WFMMod().

◆ m_audioBufferFill

uint WFMMod::m_audioBufferFill
private

Definition at line 297 of file wfmmod.h.

Referenced by pull(), pullAF(), pullAudio(), and WFMMod().

◆ m_audioFifo

AudioFifo WFMMod::m_audioFifo
private

Definition at line 298 of file wfmmod.h.

Referenced by applySettings(), pullAudio(), start(), WFMMod(), and ~WFMMod().

◆ m_audioSampleRate

quint32 WFMMod::m_audioSampleRate
private

◆ m_basebandSampleRate

int WFMMod::m_basebandSampleRate
private

Definition at line 273 of file wfmmod.h.

Referenced by applyChannelSettings(), pullAudio(), start(), and WFMMod().

◆ m_carrierNco

NCO WFMMod::m_carrierNco
private

Definition at line 278 of file wfmmod.h.

Referenced by applyChannelSettings(), and pull().

◆ m_channelId

const QString WFMMod::m_channelId = "WFMMod"
static

Definition at line 251 of file wfmmod.h.

Referenced by WFMModPlugin::initPlugin(), and WFMMod().

◆ m_channelIdURI

const QString WFMMod::m_channelIdURI = "sdrangel.channeltx.modwfm"
static

Definition at line 250 of file wfmmod.h.

Referenced by WFMModPlugin::initPlugin(), and WFMModGUI::WFMModGUI().

◆ m_channelizer

UpChannelizer* WFMMod::m_channelizer
private

Definition at line 271 of file wfmmod.h.

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

◆ m_cwKeyer

CWKeyer WFMMod::m_cwKeyer
private

◆ m_deviceAPI

DeviceAPI* WFMMod::m_deviceAPI
private

Definition at line 269 of file wfmmod.h.

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

◆ m_fileName

QString WFMMod::m_fileName
private

◆ m_fileSize

quint64 WFMMod::m_fileSize
private

raw file size (bytes)

Definition at line 305 of file wfmmod.h.

Referenced by handleMessage(), and openFileStream().

◆ m_ifstream

std::ifstream WFMMod::m_ifstream
private

Definition at line 303 of file wfmmod.h.

Referenced by handleMessage(), openFileStream(), pullAF(), and seekFileStream().

◆ m_inputFrequencyOffset

int WFMMod::m_inputFrequencyOffset
private

Definition at line 275 of file wfmmod.h.

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

◆ m_interpolator

Interpolator WFMMod::m_interpolator
private

Definition at line 282 of file wfmmod.h.

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

◆ m_interpolatorConsumed

bool WFMMod::m_interpolatorConsumed
private

Definition at line 285 of file wfmmod.h.

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

◆ m_interpolatorDistance

Real WFMMod::m_interpolatorDistance
private

Definition at line 283 of file wfmmod.h.

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

◆ m_interpolatorDistanceRemain

Real WFMMod::m_interpolatorDistanceRemain
private

Definition at line 284 of file wfmmod.h.

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

◆ m_levelCalcCount

quint32 WFMMod::m_levelCalcCount
private

Definition at line 309 of file wfmmod.h.

Referenced by calculateLevel().

◆ m_levelNbSamples

const int WFMMod::m_levelNbSamples = 480
staticprivate

Definition at line 317 of file wfmmod.h.

Referenced by calculateLevel().

◆ m_levelSum

Real WFMMod::m_levelSum
private

Definition at line 311 of file wfmmod.h.

Referenced by calculateLevel().

◆ m_magsq

double WFMMod::m_magsq
private

Definition at line 292 of file wfmmod.h.

Referenced by getMagSq(), pull(), and WFMMod().

◆ m_modPhasor

float WFMMod::m_modPhasor
private

baseband modulator phasor

Definition at line 280 of file wfmmod.h.

Referenced by pull().

◆ m_modSample

Complex WFMMod::m_modSample
private

Definition at line 281 of file wfmmod.h.

Referenced by pull().

◆ m_movingAverage

MovingAverageUtil<double, double, 16> WFMMod::m_movingAverage
private

Definition at line 293 of file wfmmod.h.

Referenced by pull().

◆ m_networkManager

QNetworkAccessManager* WFMMod::m_networkManager
private

Definition at line 314 of file wfmmod.h.

Referenced by webapiReverseSendCWSettings(), webapiReverseSendSettings(), WFMMod(), and ~WFMMod().

◆ m_networkRequest

QNetworkRequest WFMMod::m_networkRequest
private

Definition at line 315 of file wfmmod.h.

Referenced by webapiReverseSendCWSettings(), and webapiReverseSendSettings().

◆ m_outputSampleRate

int WFMMod::m_outputSampleRate
private

◆ m_peakLevel

Real WFMMod::m_peakLevel
private

Definition at line 310 of file wfmmod.h.

Referenced by calculateLevel().

◆ m_recordLength

quint32 WFMMod::m_recordLength
private

record length in seconds computed from file size

Definition at line 306 of file wfmmod.h.

Referenced by WFMMod::MsgReportFileSourceStreamData::getRecordLength(), openFileStream(), and seekFileStream().

◆ m_rfFilter

fftfilt* WFMMod::m_rfFilter
private

Definition at line 287 of file wfmmod.h.

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

◆ m_rfFilterBuffer

fftfilt::cmplx* WFMMod::m_rfFilterBuffer
private

Definition at line 289 of file wfmmod.h.

Referenced by pull(), WFMMod(), and ~WFMMod().

◆ m_rfFilterBufferIndex

int WFMMod::m_rfFilterBufferIndex
private

Definition at line 290 of file wfmmod.h.

Referenced by pull(), and WFMMod().

◆ m_rfFilterFFTLength

const int WFMMod::m_rfFilterFFTLength = 1024
staticprivate

Definition at line 288 of file wfmmod.h.

Referenced by WFMMod().

◆ m_sampleBuffer

SampleVector WFMMod::m_sampleBuffer
private

Definition at line 300 of file wfmmod.h.

◆ m_sampleRate

int WFMMod::m_sampleRate
private

◆ m_settings

WFMModSettings WFMMod::m_settings
private

◆ m_settingsMutex

QMutex WFMMod::m_settingsMutex
private

◆ m_threadedChannelizer

ThreadedBasebandSampleSource* WFMMod::m_threadedChannelizer
private

Definition at line 270 of file wfmmod.h.

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

◆ m_toneNcoRF

NCOF WFMMod::m_toneNcoRF
private

Definition at line 279 of file wfmmod.h.

Referenced by applyChannelSettings(), applySettings(), pullAF(), and WFMMod().


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