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 | List of all members
FreeDVDemod Class Reference

#include <freedvdemod.h>

+ Inheritance diagram for FreeDVDemod:
+ Collaboration diagram for FreeDVDemod:

Classes

struct  FreeDVSNR
 
struct  FreeDVStats
 
struct  LevelRMS
 
struct  MagSqLevelsStore
 
class  MsgConfigureChannelizer
 
class  MsgConfigureFreeDVDemod
 
class  MsgConfigureFreeDVDemodPrivate
 
class  MsgResyncFreeDVDemod
 

Signals

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

Public Member Functions

 FreeDVDemod (DeviceAPI *deviceAPI)
 
virtual ~FreeDVDemod ()
 
virtual void destroy ()
 
void setSampleSink (BasebandSampleSink *sampleSink)
 
void configure (MessageQueue *messageQueue, Real Bandwidth, Real LowCutoff, Real volume, int spanLog2, bool audioBinaural, bool audioFlipChannels, bool dsb, bool audioMute, bool agc, bool agcClamping, int agcTimeLog2, int agcPowerThreshold, int agcThresholdGate)
 
virtual void feed (const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool positiveOnly)
 
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
 
uint32_t getAudioSampleRate () const
 
uint32_t getModemSampleRate () const
 
double getMagSq () const
 
bool getAudioActive () const
 
void getMagSqLevels (double &avg, double &peak, int &nbSamples)
 
void getSNRLevels (double &avg, double &peak, int &nbSamples)
 
int getBER () const
 
float getFrequencyOffset () const
 
bool isSync () 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)
 
- Public Member Functions inherited from BasebandSampleSink
 BasebandSampleSink ()
 
virtual ~BasebandSampleSink ()
 
MessageQueuegetInputMessageQueue ()
 Get the queue for asynchronous inbound communication. More...
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
MessageQueuegetMessageQueueToGUI ()
 
- Public Member Functions inherited from ChannelAPI
 ChannelAPI (const QString &name, StreamType streamType)
 
virtual ~ChannelAPI ()
 
virtual void setName (const QString &name)
 
virtual const QString & getName () const
 
int getIndexInDeviceSet () const
 
void setIndexInDeviceSet (int indexInDeviceSet)
 
int getDeviceSetIndex () const
 
void setDeviceSetIndex (int deviceSetIndex)
 
DeviceAPIgetDeviceAPI ()
 
void setDeviceAPI (DeviceAPI *deviceAPI)
 
uint64_t getUID () const
 
StreamType getStreamType () const
 

Static Public Attributes

static const QString m_channelIdURI = "sdrangel.channel.freedvdemod"
 
static const QString m_channelId = "FreeDVDemod"
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void pushSampleToDV (int16_t sample)
 
void pushSampleToAudio (int16_t sample)
 
void applyChannelSettings (int inputSampleRate, int inputFrequencyOffset, bool force=false)
 
void applySettings (const FreeDVDemodSettings &settings, bool force=false)
 
void applyAudioSampleRate (int sampleRate)
 
void applyFreeDVMode (FreeDVDemodSettings::FreeDVMode mode)
 
void processOneSample (Complex &ci)
 
void webapiFormatChannelSettings (SWGSDRangel::SWGChannelSettings &response, const FreeDVDemodSettings &settings)
 
void webapiFormatChannelReport (SWGSDRangel::SWGChannelReport &response)
 
void webapiReverseSendSettings (QList< QString > &channelSettingsKeys, const FreeDVDemodSettings &settings, bool force)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSinkm_threadedChannelizer
 
DownChannelizerm_channelizer
 
FreeDVDemodSettings m_settings
 
Real m_hiCutoff
 
Real m_lowCutoff
 
Real m_volume
 
int m_spanLog2
 
fftfilt::cmplx m_sum
 
int m_undersampleCount
 
int m_inputSampleRate
 
uint32_t m_modemSampleRate
 
uint32_t m_speechSampleRate
 
uint32_t m_audioSampleRate
 
int m_inputFrequencyOffset
 
bool m_audioMute
 
double m_magsq
 
double m_magsqSum
 
double m_magsqPeak
 
int m_magsqCount
 
MagSqLevelsStore m_magSqLevelStore
 
SimpleAGC< 4800 > m_simpleAGC
 
bool m_agcActive
 
DoubleBufferFIFO< fftfilt::cmplxm_squelchDelayLine
 
bool m_audioActive
 True if an audio signal is produced (no AGC or AGC and above threshold) More...
 
NCOF m_nco
 
Interpolator m_interpolator
 
Real m_interpolatorDistance
 
Real m_interpolatorDistanceRemain
 
fftfiltSSBFilter
 
BasebandSampleSinkm_sampleSink
 
SampleVector m_sampleBuffer
 
AudioVector m_audioBuffer
 
uint m_audioBufferFill
 
AudioFifo m_audioFifo
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 
struct freedv * m_freeDV
 
int m_nSpeechSamples
 
int m_nMaxModemSamples
 
int m_nin
 
int m_iSpeech
 
int m_iModem
 
int16_tm_speechOut
 
int16_tm_modIn
 
AudioResampler m_audioResampler
 
FreeDVStats m_freeDVStats
 
FreeDVSNR m_freeDVSNR
 
LevelRMS m_levelIn
 
int m_levelInNbSamples
 
QMutex m_settingsMutex
 

Additional Inherited Members

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

Detailed Description

Definition at line 50 of file freedvdemod.h.

Constructor & Destructor Documentation

◆ FreeDVDemod()

FreeDVDemod::FreeDVDemod ( DeviceAPI deviceAPI)

Definition at line 148 of file freedvdemod.cpp.

References AudioDeviceManager::addAudioSink(), DeviceAPI::addChannelSink(), DeviceAPI::addChannelSinkAPI(), applyAudioSampleRate(), applyChannelSettings(), applySettings(), DSPEngine::getAudioDeviceManager(), BasebandSampleSink::getInputMessageQueue(), AudioDeviceManager::getOutputSampleRate(), DSPEngine::instance(), m_agcActive, m_audioActive, m_audioBuffer, m_audioBufferFill, m_audioFifo, m_audioMute, m_channelId, m_channelizer, m_deviceAPI, m_freeDV, m_hiCutoff, m_iModem, m_inputFrequencyOffset, m_inputSampleRate, m_iSpeech, m_levelInNbSamples, m_lowCutoff, m_magsq, m_magsqCount, m_magsqPeak, m_magsqSum, m_modemSampleRate, m_modIn, m_networkManager, m_nMaxModemSamples, m_nSpeechSamples, m_sampleSink, m_settings, m_settingsMutex, m_simpleAGC, m_speechOut, m_speechSampleRate, m_squelchDelayLine, m_threadedChannelizer, m_undersampleCount, networkManagerFinished(), SimpleAGC< AvgSize >::resizeNew(), ssbFftLen, and SSBFilter.

Referenced by FreeDVDemod::MsgConfigureChannelizer::MsgConfigureChannelizer().

148  :
150  m_deviceAPI(deviceAPI),
151  m_hiCutoff(6000),
152  m_lowCutoff(0),
153  m_volume(2),
154  m_spanLog2(3),
155  m_sum(fftfilt::cmplx{0,0}),
156  m_inputSampleRate(48000),
157  m_modemSampleRate(48000),
158  m_speechSampleRate(8000), // fixed 8 kS/s
160  m_audioMute(false),
161  m_simpleAGC(0.003f, 0.0f, 1e-6f),
162  m_agcActive(false),
163  m_squelchDelayLine(2*48000),
164  m_audioActive(false),
165  m_sampleSink(0),
166  m_audioFifo(24000),
167  m_freeDV(0),
168  m_nSpeechSamples(0),
170  m_iSpeech(0),
171  m_iModem(0),
172  m_speechOut(0),
173  m_modIn(0),
174  m_levelInNbSamples(480), // 10ms @ 48 kS/s
175  m_settingsMutex(QMutex::Recursive)
176 {
177  setObjectName(m_channelId);
178 
181  applyAudioSampleRate(audioSampleRate);
182 
183  m_audioBuffer.resize(1<<14);
184  m_audioBufferFill = 0;
185  m_undersampleCount = 0;
186 
187  m_magsq = 0.0f;
188  m_magsqSum = 0.0f;
189  m_magsqPeak = 0.0f;
190  m_magsqCount = 0;
191 
193 
195 
197  applySettings(m_settings, true);
198 
199  m_channelizer = new DownChannelizer(this);
203 
204  m_networkManager = new QNetworkAccessManager();
205  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
206 }
int16_t * m_speechOut
Definition: freedvdemod.h:402
QMutex m_settingsMutex
Definition: freedvdemod.h:410
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
DeviceAPI * m_deviceAPI
Definition: freedvdemod.h:353
Real m_lowCutoff
Definition: freedvdemod.h:359
int getOutputSampleRate(int outputDeviceIndex=-1)
AudioFifo m_audioFifo
Definition: freedvdemod.h:391
bool m_agcActive
Definition: freedvdemod.h:376
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
int16_t * m_modIn
Definition: freedvdemod.h:403
void applyAudioSampleRate(int sampleRate)
void applySettings(const FreeDVDemodSettings &settings, bool force=false)
static const QString m_channelId
Definition: freedvdemod.h:197
int m_inputSampleRate
Definition: freedvdemod.h:364
fftfilt::cmplx m_sum
Definition: freedvdemod.h:362
int m_magsqCount
Definition: freedvdemod.h:373
BasebandSampleSink * m_sampleSink
Definition: freedvdemod.h:386
AudioVector m_audioBuffer
Definition: freedvdemod.h:389
uint32_t m_modemSampleRate
Definition: freedvdemod.h:365
static const QString m_channelIdURI
Definition: freedvdemod.h:196
QNetworkAccessManager * m_networkManager
Definition: freedvdemod.h:393
DoubleBufferFIFO< fftfilt::cmplx > m_squelchDelayLine
Definition: freedvdemod.h:377
std::complex< float > cmplx
Definition: fftfilt.h:21
unsigned int uint32_t
Definition: rtptypes_win.h:46
double m_magsqSum
Definition: freedvdemod.h:371
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
double m_magsq
Definition: freedvdemod.h:370
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: freedvdemod.h:354
static DSPEngine * instance()
Definition: dspengine.cpp:51
int m_levelInNbSamples
Definition: freedvdemod.h:408
int m_nSpeechSamples
Definition: freedvdemod.h:397
bool m_audioActive
True if an audio signal is produced (no AGC or AGC and above threshold)
Definition: freedvdemod.h:378
uint m_audioBufferFill
Definition: freedvdemod.h:390
int m_nMaxModemSamples
Definition: freedvdemod.h:398
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
int m_inputFrequencyOffset
Definition: freedvdemod.h:368
bool m_audioMute
Definition: freedvdemod.h:369
double m_magsqPeak
Definition: freedvdemod.h:372
uint32_t m_speechSampleRate
Definition: freedvdemod.h:366
Exposes a single sink stream (input, Rx)
Definition: channelapi.h:41
int m_undersampleCount
Definition: freedvdemod.h:363
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
void resizeNew(uint32_t newSize, Real initial, Real cutoff=0, Real clip=0)
Definition: agc.h:95
struct freedv * m_freeDV
Definition: freedvdemod.h:396
SimpleAGC< 4800 > m_simpleAGC
Definition: freedvdemod.h:375
Real m_hiCutoff
Definition: freedvdemod.h:358
fftfilt * SSBFilter
Definition: freedvdemod.h:384
void networkManagerFinished(QNetworkReply *reply)
#define ssbFftLen
Definition: chanalyzer.h:38
DownChannelizer * m_channelizer
Definition: freedvdemod.h:355
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~FreeDVDemod()

FreeDVDemod::~FreeDVDemod ( )
virtual

Definition at line 208 of file freedvdemod.cpp.

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

Referenced by FreeDVDemod::MsgConfigureChannelizer::MsgConfigureChannelizer().

209 {
210  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
211  delete m_networkManager;
213 
216  delete m_threadedChannelizer;
217  delete m_channelizer;
218  delete SSBFilter;
219 }
DeviceAPI * m_deviceAPI
Definition: freedvdemod.h:353
AudioFifo m_audioFifo
Definition: freedvdemod.h:391
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
void removeAudioSink(AudioFifo *audioFifo)
Remove the audio sink.
QNetworkAccessManager * m_networkManager
Definition: freedvdemod.h:393
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: freedvdemod.h:354
static DSPEngine * instance()
Definition: dspengine.cpp:51
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
fftfilt * SSBFilter
Definition: freedvdemod.h:384
void networkManagerFinished(QNetworkReply *reply)
DownChannelizer * m_channelizer
Definition: freedvdemod.h:355
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applyAudioSampleRate()

void FreeDVDemod::applyAudioSampleRate ( int  sampleRate)
private

Definition at line 539 of file freedvdemod.cpp.

References m_audioFifo, m_audioResampler, m_audioSampleRate, m_settingsMutex, m_speechSampleRate, AudioResampler::setAudioFilters(), AudioResampler::setDecimation(), and AudioFifo::setSize().

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

540 {
541  qDebug("FreeDVDemod::applyAudioSampleRate: %d", sampleRate);
542 
543  m_settingsMutex.lock();
544  m_audioFifo.setSize(sampleRate);
546  m_audioResampler.setAudioFilters(sampleRate, sampleRate, 250, 3300, 4.0f);
547  m_settingsMutex.unlock();
548 
549  m_audioSampleRate = sampleRate;
550 }
QMutex m_settingsMutex
Definition: freedvdemod.h:410
AudioFifo m_audioFifo
Definition: freedvdemod.h:391
AudioResampler m_audioResampler
Definition: freedvdemod.h:404
void setAudioFilters(int srHigh, int srLow, int fcLow, int fcHigh, float gain=1.0f)
void setDecimation(uint32_t decimation)
uint32_t m_audioSampleRate
Definition: freedvdemod.h:367
uint32_t m_speechSampleRate
Definition: freedvdemod.h:366
bool setSize(uint32_t numSamples)
Definition: audiofifo.cpp:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyChannelSettings()

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

Definition at line 514 of file freedvdemod.cpp.

References Interpolator::create(), m_hiCutoff, m_inputFrequencyOffset, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_modemSampleRate, m_nco, m_settingsMutex, and NCOF::setFreq().

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

515 {
516  qDebug() << "FreeDVDemod::applyChannelSettings:"
517  << " inputSampleRate: " << inputSampleRate
518  << " inputFrequencyOffset: " << inputFrequencyOffset;
519 
520  if ((m_inputFrequencyOffset != inputFrequencyOffset) ||
521  (m_inputSampleRate != inputSampleRate) || force)
522  {
523  m_nco.setFreq(-inputFrequencyOffset, inputSampleRate);
524  }
525 
526  if ((m_inputSampleRate != inputSampleRate) || force)
527  {
528  m_settingsMutex.lock();
529  m_interpolator.create(16, inputSampleRate, m_hiCutoff * 1.5f, 2.0f);
531  m_interpolatorDistance = (Real) inputSampleRate / (Real) m_modemSampleRate;
532  m_settingsMutex.unlock();
533  }
534 
535  m_inputSampleRate = inputSampleRate;
536  m_inputFrequencyOffset = inputFrequencyOffset;
537 }
QMutex m_settingsMutex
Definition: freedvdemod.h:410
Interpolator m_interpolator
Definition: freedvdemod.h:381
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
int m_inputSampleRate
Definition: freedvdemod.h:364
uint32_t m_modemSampleRate
Definition: freedvdemod.h:365
Real m_interpolatorDistanceRemain
Definition: freedvdemod.h:383
Real m_interpolatorDistance
Definition: freedvdemod.h:382
int m_inputFrequencyOffset
Definition: freedvdemod.h:368
void setFreq(Real freq, Real sampleRate)
Definition: ncof.cpp:51
Real m_hiCutoff
Definition: freedvdemod.h:358
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyFreeDVMode()

void FreeDVDemod::applyFreeDVMode ( FreeDVDemodSettings::FreeDVMode  mode)
private

Definition at line 552 of file freedvdemod.cpp.

References DSPConfigureAudio::AudioOutput, Interpolator::create(), FreeDVDemod::MsgConfigureChannelizer::create(), fftfilt::create_filter(), FreeDVDemodSettings::FreeDVMode1600, FreeDVDemodSettings::FreeDVMode2400A, FreeDVDemodSettings::FreeDVMode700C, FreeDVDemodSettings::FreeDVMode700D, FreeDVDemodSettings::FreeDVMode800XA, FreeDVDemodSettings::getHiCutoff(), FreeDVDemodSettings::getLowCutoff(), BasebandSampleSink::getMessageQueueToGUI(), FreeDVDemodSettings::getModSampleRate(), FreeDVDemod::FreeDVStats::init(), FreeDVDemod::FreeDVStats::m_fps, m_freeDV, m_freeDVStats, m_hiCutoff, m_iModem, FreeDVDemodSettings::m_inputFrequencyOffset, BasebandSampleSink::m_inputMessageQueue, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_iSpeech, m_levelInNbSamples, m_lowCutoff, m_modemSampleRate, m_modIn, m_nin, m_nMaxModemSamples, m_nSpeechSamples, m_settings, m_settingsMutex, m_simpleAGC, m_speechOut, MessageQueue::push(), SimpleAGC< AvgSize >::resizeNew(), and SSBFilter.

Referenced by applySettings().

553 {
556  uint32_t modemSampleRate = FreeDVDemodSettings::getModSampleRate(mode);
557 
558  m_settingsMutex.lock();
559  SSBFilter->create_filter(m_lowCutoff / (float) modemSampleRate, m_hiCutoff / (float) modemSampleRate);
560 
561  // baseband interpolator
562  if (modemSampleRate != m_modemSampleRate)
563  {
564  MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
565  modemSampleRate, m_settings.m_inputFrequencyOffset);
566  m_inputMessageQueue.push(channelConfigMsg);
567 
569  //m_interpolatorConsumed = false;
570  m_interpolatorDistance = (Real) m_inputSampleRate / (Real) modemSampleRate;
572  m_modemSampleRate = modemSampleRate;
573 
574  m_simpleAGC.resizeNew(modemSampleRate/10, 0.003);
575  m_levelInNbSamples = m_modemSampleRate / 100; // 10ms
576 
577  if (getMessageQueueToGUI())
578  {
580  getMessageQueueToGUI()->push(cfg);
581  }
582  }
583 
584  // FreeDV object
585 
586  if (m_freeDV) {
587  freedv_close(m_freeDV);
588  }
589 
590  int fdv_mode = -1;
591 
592  switch(mode)
593  {
595  fdv_mode = FREEDV_MODE_700C;
596  break;
598  fdv_mode = FREEDV_MODE_700D;
599  break;
601  fdv_mode = FREEDV_MODE_800XA;
602  break;
604  fdv_mode = FREEDV_MODE_1600;
605  break;
607  default:
608  fdv_mode = FREEDV_MODE_2400A;
609  break;
610  }
611 
612  if (fdv_mode == FREEDV_MODE_700D)
613  {
614  struct freedv_advanced adv;
615  adv.interleave_frames = 1;
616  m_freeDV = freedv_open_advanced(fdv_mode, &adv);
617  }
618  else
619  {
620  m_freeDV = freedv_open(fdv_mode);
621  }
622 
623  if (m_freeDV)
624  {
625  freedv_set_test_frames(m_freeDV, 0);
626  freedv_set_snr_squelch_thresh(m_freeDV, -100.0);
627  freedv_set_squelch_en(m_freeDV, 0);
628  freedv_set_clip(m_freeDV, 0);
629  freedv_set_ext_vco(m_freeDV, 0);
630  freedv_set_sync(m_freeDV, FREEDV_SYNC_MANUAL);
631 
632  freedv_set_callback_txt(m_freeDV, nullptr, nullptr, nullptr);
633  freedv_set_callback_protocol(m_freeDV, nullptr, nullptr, nullptr);
634  freedv_set_callback_data(m_freeDV, nullptr, nullptr, nullptr);
635 
636  int nSpeechSamples = freedv_get_n_speech_samples(m_freeDV);
637  int nMaxModemSamples = freedv_get_n_max_modem_samples(m_freeDV);
638  int Fs = freedv_get_modem_sample_rate(m_freeDV);
639  int Rs = freedv_get_modem_symbol_rate(m_freeDV);
641 
642  if (nSpeechSamples != m_nSpeechSamples)
643  {
644  if (m_speechOut) {
645  delete[] m_speechOut;
646  }
647 
648  m_speechOut = new int16_t[nSpeechSamples];
649  m_nSpeechSamples = nSpeechSamples;
650  }
651 
652  if (nMaxModemSamples != m_nMaxModemSamples)
653  {
654  if (m_modIn) {
655  delete[] m_modIn;
656  }
657 
658  m_modIn = new int16_t[nMaxModemSamples];
659  m_nMaxModemSamples = nMaxModemSamples;
660  }
661 
662  m_iSpeech = 0;
663  m_iModem = 0;
664  m_nin = freedv_nin(m_freeDV);
665 
666  if (m_nin > 0) {
668  }
669 
670  qDebug() << "FreeDVMod::applyFreeDVMode:"
671  << " fdv_mode: " << fdv_mode
672  << " m_modemSampleRate: " << m_modemSampleRate
673  << " m_lowCutoff: " << m_lowCutoff
674  << " m_hiCutoff: " << m_hiCutoff
675  << " Fs: " << Fs
676  << " Rs: " << Rs
677  << " m_nSpeechSamples: " << m_nSpeechSamples
678  << " m_nMaxModemSamples: " << m_nMaxModemSamples
679  << " m_nin: " << m_nin
680  << " FPS: " << m_freeDVStats.m_fps;
681  }
682 
683  m_settingsMutex.unlock();
684 }
int16_t * m_speechOut
Definition: freedvdemod.h:402
short int16_t
Definition: rtptypes_win.h:43
QMutex m_settingsMutex
Definition: freedvdemod.h:410
Real m_lowCutoff
Definition: freedvdemod.h:359
Interpolator m_interpolator
Definition: freedvdemod.h:381
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
FreeDVStats m_freeDVStats
Definition: freedvdemod.h:405
int16_t * m_modIn
Definition: freedvdemod.h:403
int m_inputSampleRate
Definition: freedvdemod.h:364
uint32_t m_modemSampleRate
Definition: freedvdemod.h:365
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
unsigned int uint32_t
Definition: rtptypes_win.h:46
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
Real m_interpolatorDistanceRemain
Definition: freedvdemod.h:383
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: freedvdemod.h:96
int m_levelInNbSamples
Definition: freedvdemod.h:408
int m_nSpeechSamples
Definition: freedvdemod.h:397
int m_nMaxModemSamples
Definition: freedvdemod.h:398
Real m_interpolatorDistance
Definition: freedvdemod.h:382
MessageQueue * getMessageQueueToGUI()
void resizeNew(uint32_t newSize, Real initial, Real cutoff=0, Real clip=0)
Definition: agc.h:95
struct freedv * m_freeDV
Definition: freedvdemod.h:396
uint32_t m_fps
frames per second
Definition: freedvdemod.h:235
SimpleAGC< 4800 > m_simpleAGC
Definition: freedvdemod.h:375
Real m_hiCutoff
Definition: freedvdemod.h:358
static int getHiCutoff(FreeDVMode freeDVMode)
float Real
Definition: dsptypes.h:42
fftfilt * SSBFilter
Definition: freedvdemod.h:384
static int getLowCutoff(FreeDVMode freeDVMode)
static int getModSampleRate(FreeDVMode freeDVMode)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySettings()

void FreeDVDemod::applySettings ( const FreeDVDemodSettings settings,
bool  force = false 
)
private

Definition at line 686 of file freedvdemod.cpp.

References AudioDeviceManager::addAudioSink(), applyAudioSampleRate(), applyFreeDVMode(), DSPEngine::getAudioDeviceManager(), BasebandSampleSink::getInputMessageQueue(), AudioDeviceManager::getOutputDeviceIndex(), AudioDeviceManager::getOutputSampleRate(), DSPEngine::instance(), FreeDVDemodSettings::m_agc, m_agcActive, FreeDVDemodSettings::m_audioDeviceName, m_audioFifo, FreeDVDemodSettings::m_audioMute, m_audioMute, m_audioSampleRate, FreeDVDemodSettings::m_freeDVMode, FreeDVDemodSettings::m_inputFrequencyOffset, FreeDVDemodSettings::m_reverseAPIAddress, FreeDVDemodSettings::m_reverseAPIChannelIndex, FreeDVDemodSettings::m_reverseAPIDeviceIndex, FreeDVDemodSettings::m_reverseAPIPort, m_settings, FreeDVDemodSettings::m_spanLog2, m_spanLog2, FreeDVDemodSettings::m_useReverseAPI, FreeDVDemodSettings::m_volume, m_volume, FreeDVDemodSettings::m_volumeIn, and webapiReverseSendSettings().

Referenced by FreeDVDemod(), and handleMessage().

687 {
688  qDebug() << "FreeDVDemod::applySettings:"
689  << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
690  << " m_volume: " << settings.m_volume
691  << " m_volumeIn: " << settings.m_volumeIn
692  << " m_spanLog2: " << settings.m_spanLog2
693  << " m_audioMute: " << settings.m_audioMute
694  << " m_agcActive: " << settings.m_agc
695  << " m_audioDeviceName: " << settings.m_audioDeviceName
696  << " m_useReverseAPI: " << settings.m_useReverseAPI
697  << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
698  << " m_reverseAPIPort: " << settings.m_reverseAPIPort
699  << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
700  << " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
701  << " force: " << force;
702 
703  QList<QString> reverseAPIKeys;
704 
705  if((m_settings.m_inputFrequencyOffset != settings.m_inputFrequencyOffset) || force) {
706  reverseAPIKeys.append("inputFrequencyOffset");
707  }
708 
709  if ((m_settings.m_volume != settings.m_volume) || force)
710  {
711  reverseAPIKeys.append("volume");
712  m_volume = settings.m_volume;
713  m_volume /= 4.0; // for 3276.8
714  }
715 
716  if ((m_settings.m_volumeIn != settings.m_volumeIn) || force)
717  {
718  reverseAPIKeys.append("volumeIn");
719  }
720 
721  if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
722  {
723  reverseAPIKeys.append("audioDeviceName");
725  int audioDeviceIndex = audioDeviceManager->getOutputDeviceIndex(settings.m_audioDeviceName);
726  audioDeviceManager->addAudioSink(&m_audioFifo, getInputMessageQueue(), audioDeviceIndex);
727  uint32_t audioSampleRate = audioDeviceManager->getOutputSampleRate(audioDeviceIndex);
728 
729  if (m_audioSampleRate != audioSampleRate) {
730  applyAudioSampleRate(audioSampleRate);
731  }
732  }
733 
734  if ((m_settings.m_spanLog2 != settings.m_spanLog2) || force) {
735  reverseAPIKeys.append("spanLog2");
736  }
737  if ((m_settings.m_audioMute != settings.m_audioMute) || force) {
738  reverseAPIKeys.append("audioMute");
739  }
740  if ((m_settings.m_agc != settings.m_agc) || force) {
741  reverseAPIKeys.append("agc");
742  }
743 
744  if ((settings.m_freeDVMode != m_settings.m_freeDVMode) || force) {
745  applyFreeDVMode(settings.m_freeDVMode);
746  }
747 
748  m_spanLog2 = settings.m_spanLog2;
749  m_audioMute = settings.m_audioMute;
750  m_agcActive = settings.m_agc;
751 
752  if (settings.m_useReverseAPI)
753  {
754  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
759  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
760  }
761 
762  m_settings = settings;
763 }
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
int getOutputSampleRate(int outputDeviceIndex=-1)
AudioFifo m_audioFifo
Definition: freedvdemod.h:391
bool m_agcActive
Definition: freedvdemod.h:376
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
int getOutputDeviceIndex(const QString &deviceName) const
void applyAudioSampleRate(int sampleRate)
unsigned int uint32_t
Definition: rtptypes_win.h:46
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
uint32_t m_audioSampleRate
Definition: freedvdemod.h:367
void applyFreeDVMode(FreeDVDemodSettings::FreeDVMode mode)
static DSPEngine * instance()
Definition: dspengine.cpp:51
bool m_audioMute
Definition: freedvdemod.h:369
AudioDeviceManager * getAudioDeviceManager()
Definition: dspengine.h:55
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const FreeDVDemodSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ configure()

void FreeDVDemod::configure ( MessageQueue messageQueue,
Real  Bandwidth,
Real  LowCutoff,
Real  volume,
int  spanLog2,
bool  audioBinaural,
bool  audioFlipChannels,
bool  dsb,
bool  audioMute,
bool  agc,
bool  agcClamping,
int  agcTimeLog2,
int  agcPowerThreshold,
int  agcThresholdGate 
)

Definition at line 221 of file freedvdemod.cpp.

References FreeDVDemod::MsgConfigureFreeDVDemodPrivate::create(), and MessageQueue::push().

Referenced by setSampleSink().

235 {
237  Bandwidth,
238  LowCutoff,
239  volume,
240  spanLog2,
241  audioBinaural,
242  audioFlipChannel,
243  dsb,
244  audioMute,
245  agc,
246  agcClamping,
247  agcTimeLog2,
248  agcPowerThreshold,
249  agcThresholdGate);
250  messageQueue->push(cmd);
251 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigureFreeDVDemodPrivate * create(Real Bandwidth, Real LowCutoff, Real volume, int spanLog2, bool audioBinaural, bool audioFlipChannels, bool dsb, bool audioMute, bool agc, bool agcClamping, int agcTimeLog2, int agcPowerThreshold, int agcThresholdGate)
Definition: freedvdemod.h:278
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements ChannelAPI.

Definition at line 787 of file freedvdemod.cpp.

References FreeDVDemod::MsgConfigureFreeDVDemod::create(), FreeDVDemodSettings::deserialize(), BasebandSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and FreeDVDemodSettings::resetToDefaults().

Referenced by getCenterFrequency().

788 {
789  if (m_settings.deserialize(data))
790  {
791  MsgConfigureFreeDVDemod *msg = MsgConfigureFreeDVDemod::create(m_settings, true);
793  return true;
794  }
795  else
796  {
798  MsgConfigureFreeDVDemod *msg = MsgConfigureFreeDVDemod::create(m_settings, true);
800  return false;
801  }
802 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigureFreeDVDemod * create(const FreeDVDemodSettings &settings, bool force)
Definition: freedvdemod.h:60
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
bool deserialize(const QByteArray &data)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

virtual void FreeDVDemod::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 114 of file freedvdemod.h.

114 { delete this; }

◆ feed()

void FreeDVDemod::feed ( const SampleVector::const_iterator &  begin,
const SampleVector::const_iterator &  end,
bool  positiveOnly 
)
virtual

Implements BasebandSampleSink.

Definition at line 253 of file freedvdemod.cpp.

References Interpolator::decimate(), BasebandSampleSink::feed(), Interpolator::interpolate(), m_audioBuffer, m_audioBufferFill, m_audioFifo, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_nco, m_sampleBuffer, m_sampleSink, m_settingsMutex, m_spanLog2, NCOF::nextIQ(), processOneSample(), and AudioFifo::write().

Referenced by setSampleSink().

254 {
255  (void) positiveOnly;
256  Complex ci;
257  fftfilt::cmplx *sideband;
258  int n_out;
259 
260  m_settingsMutex.lock();
261 
262  int decim = 1<<(m_spanLog2 - 1);
263  unsigned char decim_mask = decim - 1; // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
264 
265  for(SampleVector::const_iterator it = begin; it < end; ++it)
266  {
267  Complex c(it->real(), it->imag());
268  c *= m_nco.nextIQ();
269 
270  if (m_interpolatorDistance < 1.0f) // interpolate
271  {
273  {
274  processOneSample(ci);
276  }
277  }
278  else
279  {
281  {
282  processOneSample(ci);
284  }
285  }
286  }
287 
288  uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
289 
290  if (res != m_audioBufferFill)
291  {
292  qDebug("FreeDVDemod::feed: %u/%u tail samples written", res, m_audioBufferFill);
293  }
294 
295  m_audioBufferFill = 0;
296 
297  if (m_sampleSink != 0)
298  {
299  m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
300  }
301 
302  m_sampleBuffer.clear();
303 
304  m_settingsMutex.unlock();
305 }
QMutex m_settingsMutex
Definition: freedvdemod.h:410
Interpolator m_interpolator
Definition: freedvdemod.h:381
bool decimate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:38
AudioFifo m_audioFifo
Definition: freedvdemod.h:391
bool interpolate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:53
BasebandSampleSink * m_sampleSink
Definition: freedvdemod.h:386
AudioVector m_audioBuffer
Definition: freedvdemod.h:389
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool positiveOnly)=0
std::complex< float > cmplx
Definition: fftfilt.h:21
Complex nextIQ()
Return next complex sample.
Definition: ncof.cpp:63
Real m_interpolatorDistanceRemain
Definition: freedvdemod.h:383
uint m_audioBufferFill
Definition: freedvdemod.h:390
Real m_interpolatorDistance
Definition: freedvdemod.h:382
std::complex< Real > Complex
Definition: dsptypes.h:43
SampleVector m_sampleBuffer
Definition: freedvdemod.h:387
void processOneSample(Complex &ci)
uint32_t write(const quint8 *data, uint32_t numSamples)
Definition: audiofifo.cpp:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAudioActive()

bool FreeDVDemod::getAudioActive ( ) const
inline

Definition at line 157 of file freedvdemod.h.

References m_audioActive.

Referenced by FreeDVDemodGUI::tick().

157 { return m_audioActive; }
bool m_audioActive
True if an audio signal is produced (no AGC or AGC and above threshold)
Definition: freedvdemod.h:378
+ Here is the caller graph for this function:

◆ getAudioSampleRate()

uint32_t FreeDVDemod::getAudioSampleRate ( ) const
inline

Definition at line 154 of file freedvdemod.h.

References m_audioSampleRate.

Referenced by FreeDVDemodGUI::applySettings(), and FreeDVDemodGUI::handleMessage().

154 { return m_audioSampleRate; }
uint32_t m_audioSampleRate
Definition: freedvdemod.h:367
+ Here is the caller graph for this function:

◆ getBER()

int FreeDVDemod::getBER ( ) const
inline

Definition at line 178 of file freedvdemod.h.

References FreeDVDemod::FreeDVStats::m_ber, and m_freeDVStats.

Referenced by FreeDVDemodGUI::tick().

178 { return m_freeDVStats.m_ber; }
FreeDVStats m_freeDVStats
Definition: freedvdemod.h:405
int m_ber
estimated BER (b/s)
Definition: freedvdemod.h:232
+ Here is the caller graph for this function:

◆ getCenterFrequency()

virtual qint64 FreeDVDemod::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 139 of file freedvdemod.h.

References deserialize(), FreeDVDemodSettings::m_inputFrequencyOffset, FreeDVDemod::MsgConfigureFreeDVDemod::m_settings, and serialize().

FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
+ Here is the call graph for this function:

◆ getFrequencyOffset()

float FreeDVDemod::getFrequencyOffset ( ) const
inline

Definition at line 179 of file freedvdemod.h.

References m_freeDVStats, and FreeDVDemod::FreeDVStats::m_freqOffset.

Referenced by FreeDVDemodGUI::tick().

179 { return m_freeDVStats.m_freqOffset; }
FreeDVStats m_freeDVStats
Definition: freedvdemod.h:405
+ Here is the caller graph for this function:

◆ getIdentifier()

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

Implements ChannelAPI.

Definition at line 137 of file freedvdemod.h.

137 { id = objectName(); }

◆ getMagSq()

double FreeDVDemod::getMagSq ( ) const
inline

Definition at line 156 of file freedvdemod.h.

References m_magsq.

156 { return m_magsq; }
double m_magsq
Definition: freedvdemod.h:370

◆ getMagSqLevels()

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

Definition at line 159 of file freedvdemod.h.

References getSNRLevels(), FreeDVDemod::MagSqLevelsStore::m_magsq, m_magsq, m_magsqCount, m_magSqLevelStore, FreeDVDemod::MagSqLevelsStore::m_magsqPeak, m_magsqPeak, and m_magsqSum.

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

160  {
161  if (m_magsqCount > 0)
162  {
166  }
167 
170  nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
171 
172  m_magsqSum = 0.0f;
173  m_magsqPeak = 0.0f;
174  m_magsqCount = 0;
175  }
MagSqLevelsStore m_magSqLevelStore
Definition: freedvdemod.h:374
int m_magsqCount
Definition: freedvdemod.h:373
double m_magsqSum
Definition: freedvdemod.h:371
double m_magsq
Definition: freedvdemod.h:370
double m_magsqPeak
Definition: freedvdemod.h:372
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getModemSampleRate()

uint32_t FreeDVDemod::getModemSampleRate ( ) const
inline

Definition at line 155 of file freedvdemod.h.

References m_modemSampleRate.

Referenced by FreeDVDemodGUI::displayBandwidths().

155 { return m_modemSampleRate; }
uint32_t m_modemSampleRate
Definition: freedvdemod.h:365
+ Here is the caller graph for this function:

◆ getNbSinkStreams()

virtual int FreeDVDemod::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 144 of file freedvdemod.h.

144 { return 1; }

◆ getNbSourceStreams()

virtual int FreeDVDemod::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 145 of file freedvdemod.h.

145 { return 0; }

◆ getSNRLevels()

void FreeDVDemod::getSNRLevels ( double &  avg,
double &  peak,
int &  nbSamples 
)

Definition at line 765 of file freedvdemod.cpp.

References CalcDb::dbPower(), m_freeDVSNR, FreeDVDemod::FreeDVSNR::m_n, FreeDVDemod::FreeDVSNR::m_peak, FreeDVDemod::FreeDVSNR::m_reset, and FreeDVDemod::FreeDVSNR::m_sum.

Referenced by getMagSqLevels(), and FreeDVDemodGUI::tick().

766 {
767  if (m_freeDVSNR.m_n > 0)
768  {
770  peak = m_freeDVSNR.m_peak;
771  nbSamples = m_freeDVSNR.m_n;
772  m_freeDVSNR.m_reset = true;
773  }
774  else
775  {
776  avg = 0.0;
777  peak = 0.0;
778  nbSamples = 1;
779  }
780 }
static double dbPower(double magsq, double floor=1e-12)
Definition: db.cpp:22
FreeDVSNR m_freeDVSNR
Definition: freedvdemod.h:406
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStreamCenterFrequency()

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

Implements ChannelAPI.

Definition at line 147 of file freedvdemod.h.

References FreeDVDemodSettings::m_inputFrequencyOffset, and FreeDVDemod::MsgConfigureFreeDVDemod::m_settings.

148  {
149  (void) streamIndex;
150  (void) sinkElseSource;
152  }
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356

◆ getTitle()

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

Implements ChannelAPI.

Definition at line 138 of file freedvdemod.h.

References FreeDVDemod::MsgConfigureFreeDVDemod::m_settings, and FreeDVDemodSettings::m_title.

138 { title = m_settings.m_title; }
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356

◆ handleMessage()

bool FreeDVDemod::handleMessage ( const Message cmd)
virtual

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

Implements BasebandSampleSink.

Definition at line 372 of file freedvdemod.cpp.

References applyAudioSampleRate(), applyChannelSettings(), applySettings(), DownChannelizer::configure(), FreeDVDemod::MsgConfigureChannelizer::getCenterFrequency(), FreeDVDemod::MsgConfigureFreeDVDemod::getForce(), DownChannelizer::MsgChannelizerNotification::getFrequencyOffset(), BasebandSampleSink::getInputMessageQueue(), DownChannelizer::MsgChannelizerNotification::getSampleRate(), FreeDVDemod::MsgConfigureChannelizer::getSampleRate(), DSPConfigureAudio::getSampleRate(), FreeDVDemod::MsgConfigureFreeDVDemod::getSettings(), BasebandSampleSink::MsgThreadedSink::getThread(), BasebandSampleSink::handleMessage(), m_audioSampleRate, m_channelizer, m_freeDV, m_sampleSink, m_settingsMutex, and Message::match().

Referenced by setSampleSink().

373 {
375  {
377  qDebug("FreeDVDemod::handleMessage: MsgChannelizerNotification: m_sampleRate");
378 
380 
381  return true;
382  }
383  else if (MsgConfigureChannelizer::match(cmd))
384  {
385  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
386  qDebug() << "FreeDVDemod::handleMessage: MsgConfigureChannelizer: sampleRate: " << cfg.getSampleRate()
387  << " centerFrequency: " << cfg.getCenterFrequency();
388 
390  cfg.getSampleRate(),
391  cfg.getCenterFrequency());
392 
393  return true;
394  }
395  else if (MsgConfigureFreeDVDemod::match(cmd))
396  {
397  MsgConfigureFreeDVDemod& cfg = (MsgConfigureFreeDVDemod&) cmd;
398  qDebug("FreeDVDemod::handleMessage: MsgConfigureFreeDVDemod");
399 
400  applySettings(cfg.getSettings(), cfg.getForce());
401 
402  return true;
403  }
404  else if (MsgResyncFreeDVDemod::match(cmd))
405  {
406  qDebug("FreeDVDemod::handleMessage: MsgResyncFreeDVDemod");
407  m_settingsMutex.lock();
408  freedv_set_sync(m_freeDV, FREEDV_SYNC_UNSYNC);
409  m_settingsMutex.unlock();
410  return true;
411  }
413  {
415  const QThread *thread = cfg.getThread();
416  qDebug("FreeDVDemod::handleMessage: BasebandSampleSink::MsgThreadedSink: %p", thread);
417  return true;
418  }
419  else if (DSPConfigureAudio::match(cmd))
420  {
421  DSPConfigureAudio& cfg = (DSPConfigureAudio&) cmd;
422  uint32_t sampleRate = cfg.getSampleRate();
423 
424  qDebug() << "FreeDVDemod::handleMessage: DSPConfigureAudio:"
425  << " sampleRate: " << sampleRate;
426 
427  if (sampleRate != m_audioSampleRate) {
428  applyAudioSampleRate(sampleRate);
429  }
430 
431  return true;
432  }
433  else if (DSPSignalNotification::match(cmd))
434  {
435  return true;
436  }
437  else
438  {
439  if(m_sampleSink != 0)
440  {
441  return m_sampleSink->handleMessage(cmd);
442  }
443  else
444  {
445  return false;
446  }
447  }
448 }
QMutex m_settingsMutex
Definition: freedvdemod.h:410
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void applyAudioSampleRate(int sampleRate)
void applySettings(const FreeDVDemodSettings &settings, bool force=false)
BasebandSampleSink * m_sampleSink
Definition: freedvdemod.h:386
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint32_t m_audioSampleRate
Definition: freedvdemod.h:367
virtual bool handleMessage(const Message &cmd)=0
Processing of a message. Returns true if message has actually been processed.
int getSampleRate() const
Definition: dspcommands.h:390
static bool match(const Message *message)
Definition: message.cpp:45
struct freedv * m_freeDV
Definition: freedvdemod.h:396
DownChannelizer * m_channelizer
Definition: freedvdemod.h:355
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSync()

bool FreeDVDemod::isSync ( ) const
inline

Definition at line 180 of file freedvdemod.h.

References m_freeDVStats, FreeDVDemod::FreeDVStats::m_sync, webapiReportGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

Referenced by FreeDVDemodGUI::tick().

180 { return m_freeDVStats.m_sync; }
FreeDVStats m_freeDVStats
Definition: freedvdemod.h:405
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ levelInChanged

void FreeDVDemod::levelInChanged ( 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 pushSampleToDV().

+ Here is the caller graph for this function:

◆ networkManagerFinished

void FreeDVDemod::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 1017 of file freedvdemod.cpp.

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

1018 {
1019  QNetworkReply::NetworkError replyError = reply->error();
1020 
1021  if (replyError)
1022  {
1023  qWarning() << "FreeDVDemod::networkManagerFinished:"
1024  << " error(" << (int) replyError
1025  << "): " << replyError
1026  << ": " << reply->errorString();
1027  return;
1028  }
1029 
1030  QString answer = reply->readAll();
1031  answer.chop(1); // remove last \n
1032  qDebug("FreeDVDemod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
1033 }
+ Here is the caller graph for this function:

◆ processOneSample()

void FreeDVDemod::processOneSample ( Complex ci)
private

Definition at line 307 of file freedvdemod.cpp.

References SimpleAGC< AvgSize >::feed(), SimpleAGC< AvgSize >::getValue(), i, m_agcActive, m_magsq, m_magsqCount, m_magsqPeak, m_magsqSum, m_sampleBuffer, m_settings, m_simpleAGC, m_spanLog2, m_sum, m_undersampleCount, FreeDVDemodSettings::m_volumeIn, pushSampleToDV(), fftfilt::runSSB(), SDR_RX_SCALED, and SSBFilter.

Referenced by feed().

308 {
309  fftfilt::cmplx *sideband;
310  int n_out = 0;
311  int decim = 1<<(m_spanLog2 - 1);
312  unsigned char decim_mask = decim - 1; // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
313 
314  n_out = SSBFilter->runSSB(ci, &sideband, true); // always USB side
315 
316  for (int i = 0; i < n_out; i++)
317  {
318  // Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
319  // smart decimation with bit gain using float arithmetic (23 bits significand)
320 
321  m_sum += sideband[i];
322 
323  if (!(m_undersampleCount++ & decim_mask))
324  {
325  Real avgr = m_sum.real() / decim;
326  Real avgi = m_sum.imag() / decim;
327  m_magsq = (avgr * avgr + avgi * avgi) / (SDR_RX_SCALED*SDR_RX_SCALED);
328 
329  m_magsqSum += m_magsq;
330 
331  if (m_magsq > m_magsqPeak)
332  {
334  }
335 
336  m_magsqCount++;
337  m_sampleBuffer.push_back(Sample(avgr, avgi));
338  m_sum.real(0.0);
339  m_sum.imag(0.0);
340  }
341 
342  // fftfilt::cmplx z = sideband[i];
343  // Real demod = (z.real() + z.imag()) * 0.7;
344  Real demod = sideband[i].real(); // works as good
345 
346  if (m_agcActive)
347  {
348  m_simpleAGC.feed(demod);
349  demod *= (m_settings.m_volumeIn * 3276.8f) / m_simpleAGC.getValue(); // provision for peak to average ratio (here 10) compensated by m_volumeIn
350  // if (i == 0) {
351  // qDebug("FreeDVDemod::feed: m_simpleAGC: %f", m_simpleAGC.getValue());
352  // }
353  }
354  else
355  {
356  demod *= m_settings.m_volumeIn;
357  }
358 
359  pushSampleToDV((qint16) demod);
360  }
361 }
bool m_agcActive
Definition: freedvdemod.h:376
void pushSampleToDV(int16_t sample)
fftfilt::cmplx m_sum
Definition: freedvdemod.h:362
int m_magsqCount
Definition: freedvdemod.h:373
Real getValue()
Definition: agc.h:107
std::complex< float > cmplx
Definition: fftfilt.h:21
double m_magsqSum
Definition: freedvdemod.h:371
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
double m_magsq
Definition: freedvdemod.h:370
void feed(Real value)
Definition: agc.h:116
int32_t i
Definition: decimators.h:244
double m_magsqPeak
Definition: freedvdemod.h:372
int m_undersampleCount
Definition: freedvdemod.h:363
int runSSB(const cmplx &in, cmplx **out, bool usb, bool getDC=true)
Definition: fftfilt.cpp:284
SimpleAGC< 4800 > m_simpleAGC
Definition: freedvdemod.h:375
SampleVector m_sampleBuffer
Definition: freedvdemod.h:387
#define SDR_RX_SCALED
Definition: dsptypes.h:34
float Real
Definition: dsptypes.h:42
fftfilt * SSBFilter
Definition: freedvdemod.h:384
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pushSampleToAudio()

void FreeDVDemod::pushSampleToAudio ( int16_t  sample)
private

Definition at line 496 of file freedvdemod.cpp.

References m_audioBuffer, m_audioBufferFill, m_audioFifo, m_volume, and AudioFifo::write().

Referenced by pushSampleToDV().

497 {
501 
502  if (m_audioBufferFill >= m_audioBuffer.size())
503  {
504  uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
505 
506  if (res != m_audioBufferFill) {
507  qDebug("FreeDVDemod::pushSampleToAudio: %u/%u samples written", res, m_audioBufferFill);
508  }
509 
510  m_audioBufferFill = 0;
511  }
512 }
AudioFifo m_audioFifo
Definition: freedvdemod.h:391
AudioVector m_audioBuffer
Definition: freedvdemod.h:389
uint m_audioBufferFill
Definition: freedvdemod.h:390
uint32_t write(const quint8 *data, uint32_t numSamples)
Definition: audiofifo.cpp:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pushSampleToDV()

void FreeDVDemod::pushSampleToDV ( int16_t  sample)
private

Definition at line 450 of file freedvdemod.cpp.

References FreeDVDemod::FreeDVSNR::accumulate(), FreeDVDemod::LevelRMS::accumulate(), FreeDVDemod::FreeDVStats::collect(), AudioResampler::getDecimation(), i, levelInChanged(), FreeDVDemodSettings::m_audioMute, m_audioResampler, m_freeDV, m_freeDVSNR, m_freeDVStats, m_iModem, m_iSpeech, m_levelIn, m_levelInNbSamples, m_modIn, FreeDVDemod::LevelRMS::m_n, m_nin, FreeDVDemod::LevelRMS::m_peak, FreeDVDemod::LevelRMS::m_reset, m_settings, FreeDVDemod::FreeDVStats::m_snrEst, m_speechOut, FreeDVDemod::LevelRMS::m_sum, pushSampleToAudio(), sqrt(), and AudioResampler::upSample().

Referenced by processOneSample().

451 {
452  qint16 audioSample;
453 
455  {
456  qreal rmsLevel = sqrt(m_levelIn.m_sum / m_levelInNbSamples);
457  // qDebug("FreeDVDemod::pushSampleToDV: rmsLevel: %f m_peak: %f m_levelInNbSamples: %d",
458  // rmsLevel, m_levelIn.m_peak, m_levelInNbSamples);
460  m_levelIn.m_reset = true;
461  }
462 
463  m_levelIn.accumulate(sample/29491.2f); // scale on 90% (0.9 * 32768.0)
464 
465  if (m_iModem == m_nin)
466  {
467  int nout = freedv_rx(m_freeDV, m_speechOut, m_modIn);
470 
472  {
473  for (uint32_t i = 0; i < nout * m_audioResampler.getDecimation(); i++) {
475  }
476  }
477  else
478  {
479  for (int i = 0; i < nout; i++)
480  {
481  while (!m_audioResampler.upSample(m_speechOut[i], audioSample)) {
482  pushSampleToAudio(audioSample);
483  }
484 
485  pushSampleToAudio(audioSample);
486  }
487  }
488 
489  m_iModem = 0;
490  m_iSpeech = 0;
491  }
492 
493  m_modIn[m_iModem++] = sample;
494 }
int16_t * m_speechOut
Definition: freedvdemod.h:402
bool upSample(qint16 sampleIn, qint16 &sampleOut)
void pushSampleToAudio(int16_t sample)
void levelInChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
AudioResampler m_audioResampler
Definition: freedvdemod.h:404
FreeDVStats m_freeDVStats
Definition: freedvdemod.h:405
int16_t * m_modIn
Definition: freedvdemod.h:403
uint32_t getDecimation() const
void collect(struct freedv *freedv)
Definition: freedvdemod.cpp:72
unsigned int uint32_t
Definition: rtptypes_win.h:46
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
int m_levelInNbSamples
Definition: freedvdemod.h:408
int32_t i
Definition: decimators.h:244
FreeDVSNR m_freeDVSNR
Definition: freedvdemod.h:406
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2283
void accumulate(float snrdB)
LevelRMS m_levelIn
Definition: freedvdemod.h:407
struct freedv * m_freeDV
Definition: freedvdemod.h:396
void accumulate(float fsample)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray FreeDVDemod::serialize ( ) const
virtual

Implements ChannelAPI.

Definition at line 782 of file freedvdemod.cpp.

References m_settings, and FreeDVDemodSettings::serialize().

Referenced by getCenterFrequency().

783 {
784  return m_settings.serialize();
785 }
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSampleSink()

void FreeDVDemod::setSampleSink ( BasebandSampleSink sampleSink)
inline

Definition at line 115 of file freedvdemod.h.

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

Referenced by FreeDVDemodGUI::FreeDVDemodGUI().

115 { m_sampleSink = sampleSink; }
BasebandSampleSink * m_sampleSink
Definition: freedvdemod.h:386
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

void FreeDVDemod::start ( )
virtual

Implements BasebandSampleSink.

Definition at line 363 of file freedvdemod.cpp.

References applyChannelSettings(), m_inputFrequencyOffset, and m_inputSampleRate.

Referenced by setSampleSink().

364 {
366 }
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
int m_inputSampleRate
Definition: freedvdemod.h:364
int m_inputFrequencyOffset
Definition: freedvdemod.h:368
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void FreeDVDemod::stop ( )
virtual

Implements BasebandSampleSink.

Definition at line 368 of file freedvdemod.cpp.

Referenced by setSampleSink().

369 {
370 }
+ Here is the caller graph for this function:

◆ webapiFormatChannelReport()

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

Definition at line 943 of file freedvdemod.cpp.

References CalcDb::dbPower(), SWGSDRangel::SWGChannelReport::getFreeDvDemodReport(), getMagSqLevels(), m_audioActive, m_audioSampleRate, m_inputSampleRate, SWGSDRangel::SWGFreeDVDemodReport::setAudioSampleRate(), SWGSDRangel::SWGFreeDVDemodReport::setChannelPowerDb(), SWGSDRangel::SWGFreeDVDemodReport::setChannelSampleRate(), and SWGSDRangel::SWGFreeDVDemodReport::setSquelch().

Referenced by webapiReportGet().

944 {
945  double magsqAvg, magsqPeak;
946  int nbMagsqSamples;
947  getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
948 
950  response.getFreeDvDemodReport()->setSquelch(m_audioActive ? 1 : 0);
953 }
static double dbPower(double magsq, double floor=1e-12)
Definition: db.cpp:22
int m_inputSampleRate
Definition: freedvdemod.h:364
void setChannelPowerDb(float channel_power_db)
void getMagSqLevels(double &avg, double &peak, int &nbSamples)
Definition: freedvdemod.h:159
uint32_t m_audioSampleRate
Definition: freedvdemod.h:367
bool m_audioActive
True if an audio signal is produced (no AGC or AGC and above threshold)
Definition: freedvdemod.h:378
void setAudioSampleRate(qint32 audio_sample_rate)
void setChannelSampleRate(qint32 channel_sample_rate)
SWGFreeDVDemodReport * getFreeDvDemodReport()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatChannelSettings()

void FreeDVDemod::webapiFormatChannelSettings ( SWGSDRangel::SWGChannelSettings response,
const FreeDVDemodSettings settings 
)
private

Definition at line 906 of file freedvdemod.cpp.

References SWGSDRangel::SWGFreeDVDemodSettings::getAudioDeviceName(), SWGSDRangel::SWGChannelSettings::getFreeDvDemodSettings(), SWGSDRangel::SWGFreeDVDemodSettings::getReverseApiAddress(), SWGSDRangel::SWGFreeDVDemodSettings::getTitle(), FreeDVDemodSettings::m_agc, FreeDVDemodSettings::m_audioDeviceName, FreeDVDemodSettings::m_audioMute, FreeDVDemodSettings::m_freeDVMode, FreeDVDemodSettings::m_inputFrequencyOffset, FreeDVDemodSettings::m_reverseAPIAddress, FreeDVDemodSettings::m_reverseAPIChannelIndex, FreeDVDemodSettings::m_reverseAPIDeviceIndex, FreeDVDemodSettings::m_reverseAPIPort, FreeDVDemodSettings::m_rgbColor, FreeDVDemodSettings::m_spanLog2, FreeDVDemodSettings::m_title, FreeDVDemodSettings::m_useReverseAPI, FreeDVDemodSettings::m_volume, FreeDVDemodSettings::m_volumeIn, SWGSDRangel::SWGFreeDVDemodSettings::setAgc(), SWGSDRangel::SWGFreeDVDemodSettings::setAudioDeviceName(), SWGSDRangel::SWGFreeDVDemodSettings::setAudioMute(), SWGSDRangel::SWGFreeDVDemodSettings::setFreeDvMode(), SWGSDRangel::SWGFreeDVDemodSettings::setInputFrequencyOffset(), SWGSDRangel::SWGFreeDVDemodSettings::setReverseApiAddress(), SWGSDRangel::SWGFreeDVDemodSettings::setReverseApiChannelIndex(), SWGSDRangel::SWGFreeDVDemodSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGFreeDVDemodSettings::setReverseApiPort(), SWGSDRangel::SWGFreeDVDemodSettings::setRgbColor(), SWGSDRangel::SWGFreeDVDemodSettings::setSpanLog2(), SWGSDRangel::SWGFreeDVDemodSettings::setTitle(), SWGSDRangel::SWGFreeDVDemodSettings::setUseReverseApi(), SWGSDRangel::SWGFreeDVDemodSettings::setVolume(), and SWGSDRangel::SWGFreeDVDemodSettings::setVolumeIn().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

907 {
908  response.getFreeDvDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
910  response.getFreeDvDemodSettings()->setVolume(settings.m_volume);
911  response.getFreeDvDemodSettings()->setVolumeIn(settings.m_volumeIn);
912  response.getFreeDvDemodSettings()->setSpanLog2(settings.m_spanLog2);
913  response.getFreeDvDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
914  response.getFreeDvDemodSettings()->setAgc(settings.m_agc ? 1 : 0);
915  response.getFreeDvDemodSettings()->setRgbColor(settings.m_rgbColor);
916  response.getFreeDvDemodSettings()->setFreeDvMode((int) settings.m_freeDVMode);
917 
918  if (response.getFreeDvDemodSettings()->getTitle()) {
919  *response.getFreeDvDemodSettings()->getTitle() = settings.m_title;
920  } else {
921  response.getFreeDvDemodSettings()->setTitle(new QString(settings.m_title));
922  }
923 
924  if (response.getFreeDvDemodSettings()->getAudioDeviceName()) {
926  } else {
927  response.getFreeDvDemodSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
928  }
929 
930  response.getFreeDvDemodSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
931 
932  if (response.getFreeDvDemodSettings()->getReverseApiAddress()) {
934  } else {
935  response.getFreeDvDemodSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
936  }
937 
941 }
void setAudioDeviceName(QString *audio_device_name)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiPort(qint32 reverse_api_port)
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setReverseApiAddress(QString *reverse_api_address)
SWGFreeDVDemodSettings * getFreeDvDemodSettings()
void setUseReverseApi(qint32 use_reverse_api)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

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

Reimplemented from ChannelAPI.

Definition at line 895 of file freedvdemod.cpp.

References SWGSDRangel::SWGChannelReport::getFreeDvDemodReport(), SWGSDRangel::SWGFreeDVDemodReport::init(), SWGSDRangel::SWGChannelReport::setFreeDvDemodReport(), and webapiFormatChannelReport().

Referenced by isSync().

898 {
899  (void) errorMessage;
901  response.getFreeDvDemodReport()->init();
902  webapiFormatChannelReport(response);
903  return 200;
904 }
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
void setFreeDvDemodReport(SWGFreeDVDemodReport *free_dv_demod_report)
SWGFreeDVDemodReport * getFreeDvDemodReport()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 955 of file freedvdemod.cpp.

References SWGSDRangel::SWGChannelSettings::asJson(), ChannelAPI::getDeviceSetIndex(), SWGSDRangel::SWGChannelSettings::getFreeDvDemodSettings(), ChannelAPI::getIndexInDeviceSet(), FreeDVDemodSettings::m_agc, FreeDVDemodSettings::m_audioDeviceName, FreeDVDemodSettings::m_audioMute, FreeDVDemodSettings::m_freeDVMode, FreeDVDemodSettings::m_inputFrequencyOffset, m_networkManager, m_networkRequest, FreeDVDemodSettings::m_reverseAPIAddress, FreeDVDemodSettings::m_reverseAPIChannelIndex, FreeDVDemodSettings::m_reverseAPIDeviceIndex, FreeDVDemodSettings::m_reverseAPIPort, FreeDVDemodSettings::m_rgbColor, FreeDVDemodSettings::m_spanLog2, FreeDVDemodSettings::m_title, FreeDVDemodSettings::m_volume, FreeDVDemodSettings::m_volumeIn, SWGSDRangel::SWGFreeDVDemodSettings::setAgc(), SWGSDRangel::SWGFreeDVDemodSettings::setAudioDeviceName(), SWGSDRangel::SWGFreeDVDemodSettings::setAudioMute(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGChannelSettings::setFreeDvDemodSettings(), SWGSDRangel::SWGFreeDVDemodSettings::setFreeDvMode(), SWGSDRangel::SWGFreeDVDemodSettings::setInputFrequencyOffset(), SWGSDRangel::SWGChannelSettings::setOriginatorChannelIndex(), SWGSDRangel::SWGChannelSettings::setOriginatorDeviceSetIndex(), SWGSDRangel::SWGFreeDVDemodSettings::setRgbColor(), SWGSDRangel::SWGFreeDVDemodSettings::setSpanLog2(), SWGSDRangel::SWGFreeDVDemodSettings::setTitle(), SWGSDRangel::SWGFreeDVDemodSettings::setVolume(), and SWGSDRangel::SWGFreeDVDemodSettings::setVolumeIn().

Referenced by applySettings().

956 {
958  swgChannelSettings->setDirection(0); // single sink (Rx)
959  swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
960  swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
961  swgChannelSettings->setChannelType(new QString("SSBDemod"));
963  SWGSDRangel::SWGFreeDVDemodSettings *swgFreeDVDemodSettings = swgChannelSettings->getFreeDvDemodSettings();
964 
965  // transfer data that has been modified. When force is on transfer all data except reverse API data
966 
967  if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
968  swgFreeDVDemodSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
969  }
970  if (channelSettingsKeys.contains("freeDVMode") || force) {
971  swgFreeDVDemodSettings->setFreeDvMode((int) settings.m_freeDVMode);
972  }
973  if (channelSettingsKeys.contains("volume") || force) {
974  swgFreeDVDemodSettings->setVolume(settings.m_volume);
975  }
976  if (channelSettingsKeys.contains("volumeIn") || force) {
977  swgFreeDVDemodSettings->setVolumeIn(settings.m_volumeIn);
978  }
979  if (channelSettingsKeys.contains("spanLog2") || force) {
980  swgFreeDVDemodSettings->setSpanLog2(settings.m_spanLog2);
981  }
982  if (channelSettingsKeys.contains("audioMute") || force) {
983  swgFreeDVDemodSettings->setAudioMute(settings.m_audioMute ? 1 : 0);
984  }
985  if (channelSettingsKeys.contains("agc") || force) {
986  swgFreeDVDemodSettings->setAgc(settings.m_agc ? 1 : 0);
987  }
988  if (channelSettingsKeys.contains("rgbColor") || force) {
989  swgFreeDVDemodSettings->setRgbColor(settings.m_rgbColor);
990  }
991  if (channelSettingsKeys.contains("title") || force) {
992  swgFreeDVDemodSettings->setTitle(new QString(settings.m_title));
993  }
994  if (channelSettingsKeys.contains("audioDeviceName") || force) {
995  swgFreeDVDemodSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
996  }
997 
998  QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
999  .arg(settings.m_reverseAPIAddress)
1000  .arg(settings.m_reverseAPIPort)
1001  .arg(settings.m_reverseAPIDeviceIndex)
1002  .arg(settings.m_reverseAPIChannelIndex);
1003  m_networkRequest.setUrl(QUrl(channelSettingsURL));
1004  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
1005 
1006  QBuffer *buffer=new QBuffer();
1007  buffer->open((QBuffer::ReadWrite));
1008  buffer->write(swgChannelSettings->asJson().toUtf8());
1009  buffer->seek(0);
1010 
1011  // Always use PATCH to avoid passing reverse API settings
1012  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
1013 
1014  delete swgChannelSettings;
1015 }
void setOriginatorChannelIndex(qint32 originator_channel_index)
void setAudioDeviceName(QString *audio_device_name)
int getDeviceSetIndex() const
Definition: channelapi.h:89
QNetworkAccessManager * m_networkManager
Definition: freedvdemod.h:393
void setChannelType(QString *channel_type)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
void setInputFrequencyOffset(qint64 input_frequency_offset)
QNetworkRequest m_networkRequest
Definition: freedvdemod.h:394
virtual QString asJson() override
void setFreeDvDemodSettings(SWGFreeDVDemodSettings *free_dv_demod_settings)
SWGFreeDVDemodSettings * getFreeDvDemodSettings()
int getIndexInDeviceSet() const
Definition: channelapi.h:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

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

Reimplemented from ChannelAPI.

Definition at line 804 of file freedvdemod.cpp.

References SWGSDRangel::SWGChannelSettings::getFreeDvDemodSettings(), SWGSDRangel::SWGFreeDVDemodSettings::init(), m_settings, SWGSDRangel::SWGChannelSettings::setFreeDvDemodSettings(), and webapiFormatChannelSettings().

Referenced by isSync().

807 {
808  (void) errorMessage;
810  response.getFreeDvDemodSettings()->init();
812  return 200;
813 }
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const FreeDVDemodSettings &settings)
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
void setFreeDvDemodSettings(SWGFreeDVDemodSettings *free_dv_demod_settings)
SWGFreeDVDemodSettings * getFreeDvDemodSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from ChannelAPI.

Definition at line 815 of file freedvdemod.cpp.

References FreeDVDemod::MsgConfigureFreeDVDemod::create(), FreeDVDemod::MsgConfigureChannelizer::create(), SWGSDRangel::SWGFreeDVDemodSettings::getAgc(), SWGSDRangel::SWGFreeDVDemodSettings::getAudioDeviceName(), SWGSDRangel::SWGFreeDVDemodSettings::getAudioMute(), SWGSDRangel::SWGChannelSettings::getFreeDvDemodSettings(), SWGSDRangel::SWGFreeDVDemodSettings::getFreeDvMode(), SWGSDRangel::SWGFreeDVDemodSettings::getInputFrequencyOffset(), SWGSDRangel::SWGFreeDVDemodSettings::getReverseApiAddress(), SWGSDRangel::SWGFreeDVDemodSettings::getReverseApiChannelIndex(), SWGSDRangel::SWGFreeDVDemodSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGFreeDVDemodSettings::getReverseApiPort(), SWGSDRangel::SWGFreeDVDemodSettings::getRgbColor(), SWGSDRangel::SWGFreeDVDemodSettings::getSpanLog2(), SWGSDRangel::SWGFreeDVDemodSettings::getTitle(), SWGSDRangel::SWGFreeDVDemodSettings::getUseReverseApi(), SWGSDRangel::SWGFreeDVDemodSettings::getVolume(), SWGSDRangel::SWGFreeDVDemodSettings::getVolumeIn(), FreeDVDemodSettings::m_agc, FreeDVDemodSettings::m_audioDeviceName, FreeDVDemodSettings::m_audioMute, FreeDVDemodSettings::m_freeDVMode, BasebandSampleSink::m_guiMessageQueue, FreeDVDemodSettings::m_inputFrequencyOffset, BasebandSampleSink::m_inputMessageQueue, m_modemSampleRate, FreeDVDemodSettings::m_reverseAPIAddress, FreeDVDemodSettings::m_reverseAPIChannelIndex, FreeDVDemodSettings::m_reverseAPIDeviceIndex, FreeDVDemodSettings::m_reverseAPIPort, FreeDVDemodSettings::m_rgbColor, m_settings, FreeDVDemodSettings::m_spanLog2, FreeDVDemodSettings::m_title, FreeDVDemodSettings::m_useReverseAPI, FreeDVDemodSettings::m_volume, FreeDVDemodSettings::m_volumeIn, MessageQueue::push(), and webapiFormatChannelSettings().

Referenced by isSync().

820 {
821  (void) errorMessage;
822  FreeDVDemodSettings settings = m_settings;
823  bool frequencyOffsetChanged = false;
824 
825  if (channelSettingsKeys.contains("inputFrequencyOffset"))
826  {
828  frequencyOffsetChanged = true;
829  }
830  if (channelSettingsKeys.contains("freeDVMode")) {
832  }
833  if (channelSettingsKeys.contains("volume")) {
834  settings.m_volume = response.getFreeDvDemodSettings()->getVolume();
835  }
836  if (channelSettingsKeys.contains("volumeIn")) {
837  settings.m_volumeIn = response.getFreeDvDemodSettings()->getVolumeIn();
838  }
839  if (channelSettingsKeys.contains("spanLog2")) {
840  settings.m_spanLog2 = response.getFreeDvDemodSettings()->getSpanLog2();
841  }
842  if (channelSettingsKeys.contains("audioMute")) {
843  settings.m_audioMute = response.getFreeDvDemodSettings()->getAudioMute() != 0;
844  }
845  if (channelSettingsKeys.contains("agc")) {
846  settings.m_agc = response.getFreeDvDemodSettings()->getAgc() != 0;
847  }
848  if (channelSettingsKeys.contains("rgbColor")) {
849  settings.m_rgbColor = response.getFreeDvDemodSettings()->getRgbColor();
850  }
851  if (channelSettingsKeys.contains("title")) {
852  settings.m_title = *response.getFreeDvDemodSettings()->getTitle();
853  }
854  if (channelSettingsKeys.contains("audioDeviceName")) {
856  }
857  if (channelSettingsKeys.contains("useReverseAPI")) {
858  settings.m_useReverseAPI = response.getFreeDvDemodSettings()->getUseReverseApi() != 0;
859  }
860  if (channelSettingsKeys.contains("reverseAPIAddress")) {
862  }
863  if (channelSettingsKeys.contains("reverseAPIPort")) {
865  }
866  if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
868  }
869  if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
871  }
872 
873  if (frequencyOffsetChanged)
874  {
875  MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
877  m_inputMessageQueue.push(channelConfigMsg);
878  }
879 
880  MsgConfigureFreeDVDemod *msg = MsgConfigureFreeDVDemod::create(settings, force);
882 
883  qDebug("FreeDVDemod::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
884  if (m_guiMessageQueue) // forward to GUI if any
885  {
886  MsgConfigureFreeDVDemod *msgToGUI = MsgConfigureFreeDVDemod::create(settings, force);
887  m_guiMessageQueue->push(msgToGUI);
888  }
889 
890  webapiFormatChannelSettings(response, settings);
891 
892  return 200;
893 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigureFreeDVDemod * create(const FreeDVDemodSettings &settings, bool force)
Definition: freedvdemod.h:60
uint32_t m_modemSampleRate
Definition: freedvdemod.h:365
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const FreeDVDemodSettings &settings)
FreeDVDemodSettings m_settings
Definition: freedvdemod.h:356
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
static MsgConfigureChannelizer * create(int sampleRate, int centerFrequency)
Definition: freedvdemod.h:96
SWGFreeDVDemodSettings * getFreeDvDemodSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_agcActive

bool FreeDVDemod::m_agcActive
private

Definition at line 376 of file freedvdemod.h.

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

◆ m_audioActive

bool FreeDVDemod::m_audioActive
private

True if an audio signal is produced (no AGC or AGC and above threshold)

Definition at line 378 of file freedvdemod.h.

Referenced by FreeDVDemod(), getAudioActive(), and webapiFormatChannelReport().

◆ m_audioBuffer

AudioVector FreeDVDemod::m_audioBuffer
private

Definition at line 389 of file freedvdemod.h.

Referenced by feed(), FreeDVDemod(), and pushSampleToAudio().

◆ m_audioBufferFill

uint FreeDVDemod::m_audioBufferFill
private

Definition at line 390 of file freedvdemod.h.

Referenced by feed(), FreeDVDemod(), and pushSampleToAudio().

◆ m_audioFifo

AudioFifo FreeDVDemod::m_audioFifo
private

◆ m_audioMute

bool FreeDVDemod::m_audioMute
private

◆ m_audioResampler

AudioResampler FreeDVDemod::m_audioResampler
private

Definition at line 404 of file freedvdemod.h.

Referenced by applyAudioSampleRate(), and pushSampleToDV().

◆ m_audioSampleRate

uint32_t FreeDVDemod::m_audioSampleRate
private

◆ m_channelId

const QString FreeDVDemod::m_channelId = "FreeDVDemod"
static

Definition at line 197 of file freedvdemod.h.

Referenced by FreeDVDemod(), and FreeDVPlugin::initPlugin().

◆ m_channelIdURI

const QString FreeDVDemod::m_channelIdURI = "sdrangel.channel.freedvdemod"
static

Definition at line 196 of file freedvdemod.h.

Referenced by FreeDVDemodGUI::FreeDVDemodGUI(), and FreeDVPlugin::initPlugin().

◆ m_channelizer

DownChannelizer* FreeDVDemod::m_channelizer
private

Definition at line 355 of file freedvdemod.h.

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

◆ m_deviceAPI

DeviceAPI* FreeDVDemod::m_deviceAPI
private

Definition at line 353 of file freedvdemod.h.

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

◆ m_freeDV

struct freedv* FreeDVDemod::m_freeDV
private

Definition at line 396 of file freedvdemod.h.

Referenced by applyFreeDVMode(), FreeDVDemod(), handleMessage(), and pushSampleToDV().

◆ m_freeDVSNR

FreeDVSNR FreeDVDemod::m_freeDVSNR
private

Definition at line 406 of file freedvdemod.h.

Referenced by getSNRLevels(), and pushSampleToDV().

◆ m_freeDVStats

FreeDVStats FreeDVDemod::m_freeDVStats
private

Definition at line 405 of file freedvdemod.h.

Referenced by applyFreeDVMode(), getBER(), getFrequencyOffset(), isSync(), and pushSampleToDV().

◆ m_hiCutoff

Real FreeDVDemod::m_hiCutoff
private

Definition at line 358 of file freedvdemod.h.

Referenced by applyChannelSettings(), applyFreeDVMode(), and FreeDVDemod().

◆ m_iModem

int FreeDVDemod::m_iModem
private

Definition at line 401 of file freedvdemod.h.

Referenced by applyFreeDVMode(), FreeDVDemod(), and pushSampleToDV().

◆ m_inputFrequencyOffset

int FreeDVDemod::m_inputFrequencyOffset
private

Definition at line 368 of file freedvdemod.h.

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

◆ m_inputSampleRate

int FreeDVDemod::m_inputSampleRate
private

◆ m_interpolator

Interpolator FreeDVDemod::m_interpolator
private

Definition at line 381 of file freedvdemod.h.

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

◆ m_interpolatorDistance

Real FreeDVDemod::m_interpolatorDistance
private

Definition at line 382 of file freedvdemod.h.

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

◆ m_interpolatorDistanceRemain

Real FreeDVDemod::m_interpolatorDistanceRemain
private

Definition at line 383 of file freedvdemod.h.

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

◆ m_iSpeech

int FreeDVDemod::m_iSpeech
private

Definition at line 400 of file freedvdemod.h.

Referenced by applyFreeDVMode(), FreeDVDemod(), and pushSampleToDV().

◆ m_levelIn

LevelRMS FreeDVDemod::m_levelIn
private

Definition at line 407 of file freedvdemod.h.

Referenced by pushSampleToDV().

◆ m_levelInNbSamples

int FreeDVDemod::m_levelInNbSamples
private

Definition at line 408 of file freedvdemod.h.

Referenced by applyFreeDVMode(), FreeDVDemod(), and pushSampleToDV().

◆ m_lowCutoff

Real FreeDVDemod::m_lowCutoff
private

Definition at line 359 of file freedvdemod.h.

Referenced by applyFreeDVMode(), and FreeDVDemod().

◆ m_magsq

double FreeDVDemod::m_magsq
private

Definition at line 370 of file freedvdemod.h.

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

◆ m_magsqCount

int FreeDVDemod::m_magsqCount
private

Definition at line 373 of file freedvdemod.h.

Referenced by FreeDVDemod(), getMagSqLevels(), and processOneSample().

◆ m_magSqLevelStore

MagSqLevelsStore FreeDVDemod::m_magSqLevelStore
private

Definition at line 374 of file freedvdemod.h.

Referenced by getMagSqLevels().

◆ m_magsqPeak

double FreeDVDemod::m_magsqPeak
private

Definition at line 372 of file freedvdemod.h.

Referenced by FreeDVDemod(), getMagSqLevels(), and processOneSample().

◆ m_magsqSum

double FreeDVDemod::m_magsqSum
private

Definition at line 371 of file freedvdemod.h.

Referenced by FreeDVDemod(), getMagSqLevels(), and processOneSample().

◆ m_modemSampleRate

uint32_t FreeDVDemod::m_modemSampleRate
private

◆ m_modIn

int16_t* FreeDVDemod::m_modIn
private

Definition at line 403 of file freedvdemod.h.

Referenced by applyFreeDVMode(), FreeDVDemod(), and pushSampleToDV().

◆ m_nco

NCOF FreeDVDemod::m_nco
private

Definition at line 380 of file freedvdemod.h.

Referenced by applyChannelSettings(), and feed().

◆ m_networkManager

QNetworkAccessManager* FreeDVDemod::m_networkManager
private

Definition at line 393 of file freedvdemod.h.

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

◆ m_networkRequest

QNetworkRequest FreeDVDemod::m_networkRequest
private

Definition at line 394 of file freedvdemod.h.

Referenced by webapiReverseSendSettings().

◆ m_nin

int FreeDVDemod::m_nin
private

Definition at line 399 of file freedvdemod.h.

Referenced by applyFreeDVMode(), and pushSampleToDV().

◆ m_nMaxModemSamples

int FreeDVDemod::m_nMaxModemSamples
private

Definition at line 398 of file freedvdemod.h.

Referenced by applyFreeDVMode(), and FreeDVDemod().

◆ m_nSpeechSamples

int FreeDVDemod::m_nSpeechSamples
private

Definition at line 397 of file freedvdemod.h.

Referenced by applyFreeDVMode(), and FreeDVDemod().

◆ m_sampleBuffer

SampleVector FreeDVDemod::m_sampleBuffer
private

Definition at line 387 of file freedvdemod.h.

Referenced by feed(), and processOneSample().

◆ m_sampleSink

BasebandSampleSink* FreeDVDemod::m_sampleSink
private

Definition at line 386 of file freedvdemod.h.

Referenced by feed(), FreeDVDemod(), handleMessage(), and setSampleSink().

◆ m_settings

FreeDVDemodSettings FreeDVDemod::m_settings
private

◆ m_settingsMutex

QMutex FreeDVDemod::m_settingsMutex
private

◆ m_simpleAGC

SimpleAGC<4800> FreeDVDemod::m_simpleAGC
private

Definition at line 375 of file freedvdemod.h.

Referenced by applyFreeDVMode(), FreeDVDemod(), and processOneSample().

◆ m_spanLog2

int FreeDVDemod::m_spanLog2
private

◆ m_speechOut

int16_t* FreeDVDemod::m_speechOut
private

Definition at line 402 of file freedvdemod.h.

Referenced by applyFreeDVMode(), FreeDVDemod(), and pushSampleToDV().

◆ m_speechSampleRate

uint32_t FreeDVDemod::m_speechSampleRate
private

Definition at line 366 of file freedvdemod.h.

Referenced by applyAudioSampleRate(), and FreeDVDemod().

◆ m_squelchDelayLine

DoubleBufferFIFO<fftfilt::cmplx> FreeDVDemod::m_squelchDelayLine
private

Definition at line 377 of file freedvdemod.h.

Referenced by FreeDVDemod().

◆ m_sum

fftfilt::cmplx FreeDVDemod::m_sum
private

◆ m_threadedChannelizer

ThreadedBasebandSampleSink* FreeDVDemod::m_threadedChannelizer
private

Definition at line 354 of file freedvdemod.h.

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

◆ m_undersampleCount

int FreeDVDemod::m_undersampleCount
private

Definition at line 363 of file freedvdemod.h.

Referenced by FreeDVDemod(), and processOneSample().

◆ m_volume

Real FreeDVDemod::m_volume
private

◆ SSBFilter

fftfilt* FreeDVDemod::SSBFilter
private

Definition at line 384 of file freedvdemod.h.

Referenced by applyFreeDVMode(), FreeDVDemod(), processOneSample(), and ~FreeDVDemod().


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