SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
ChannelAnalyzer Class Reference

#include <chanalyzer.h>

+ Inheritance diagram for ChannelAnalyzer:
+ Collaboration diagram for ChannelAnalyzer:

Classes

class  MsgConfigureChannelAnalyzer
 
class  MsgConfigureChannelizer
 
class  MsgReportChannelSampleRateChanged
 

Public Member Functions

 ChannelAnalyzer (DeviceAPI *deviceAPI)
 
virtual ~ChannelAnalyzer ()
 
virtual void destroy ()
 
void setSampleSink (BasebandSampleSink *sampleSink)
 
DownChannelizergetChannelizer ()
 
int getInputSampleRate () const
 
int getChannelSampleRate () const
 
int getDecimation () const
 
double getMagSq () const
 
double getMagSqAvg () const
 
bool isPllLocked () const
 
Real getPllFrequency () const
 
Real getPllDeltaPhase () const
 
Real getPllPhase () const
 
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
 
- 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
 
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)
 
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.chanalyzer"
 
static const QString m_channelId = "ChannelAnalyzer"
 

Private Member Functions

void applyChannelSettings (int inputSampleRate, int inputFrequencyOffset, bool force=false)
 
void applySettings (const ChannelAnalyzerSettings &settings, bool force=false)
 
void setFilters (int sampleRate, float bandwidth, float lowCutoff)
 
void processOneSample (Complex &c, fftfilt::cmplx *sideband)
 
void feedOneSample (const fftfilt::cmplx &s, const fftfilt::cmplx &pll)
 

Private Attributes

DeviceAPIm_deviceAPI
 
ThreadedBasebandSampleSinkm_threadedChannelizer
 
DownChannelizerm_channelizer
 
ChannelAnalyzerSettings m_settings
 
int m_inputSampleRate
 
int m_inputFrequencyOffset
 
int m_undersampleCount
 
fftfilt::cmplx m_sum
 
bool m_usb
 
double m_magsq
 
bool m_useInterpolator
 
NCOF m_nco
 
PhaseLockComplex m_pll
 
FreqLockComplex m_fll
 
Interpolator m_interpolator
 
Real m_interpolatorDistance
 
Real m_interpolatorDistanceRemain
 
fftfiltSSBFilter
 
fftfiltDSBFilter
 
fftfiltRRCFilter
 
fftcorrm_corr
 
BasebandSampleSinkm_sampleSink
 
SampleVector m_sampleBuffer
 
MovingAverageUtil< double, double, 480 > m_channelPowerAvg
 
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 44 of file chanalyzer.h.

Constructor & Destructor Documentation

◆ ChannelAnalyzer()

ChannelAnalyzer::ChannelAnalyzer ( DeviceAPI deviceAPI)

Definition at line 35 of file chanalyzer.cpp.

References DeviceAPI::addChannelSink(), DeviceAPI::addChannelSinkAPI(), applyChannelSettings(), applySettings(), PhaseLockComplex::computeCoefficients(), DSBFilter, ChannelAnalyzerSettings::m_bandwidth, m_channelId, m_channelizer, m_corr, m_deviceAPI, m_inputFrequencyOffset, m_inputSampleRate, m_interpolatorDistance, m_interpolatorDistanceRemain, ChannelAnalyzerSettings::m_lowCutoff, m_magsq, m_pll, m_settings, m_sum, m_threadedChannelizer, m_undersampleCount, m_usb, m_useInterpolator, RRCFilter, ssbFftLen, and SSBFilter.

Referenced by ChannelAnalyzer::MsgReportChannelSampleRateChanged::MsgReportChannelSampleRateChanged().

35  :
37  m_deviceAPI(deviceAPI),
38  m_sampleSink(0),
39  m_settingsMutex(QMutex::Recursive)
40 {
41  setObjectName(m_channelId);
42 
44  m_sum = 0;
45  m_usb = true;
46  m_magsq = 0;
47  m_useInterpolator = false;
50  m_inputSampleRate = 48000;
55  m_corr = new fftcorr(8*ssbFftLen); // 8k for 4k effective samples
56  m_pll.computeCoefficients(0.002f, 0.5f, 10.0f); // bandwidth, damping factor, loop gain
57 
60 
61  m_channelizer = new DownChannelizer(this);
65 }
DownChannelizer * m_channelizer
Definition: chanalyzer.h:163
void addChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:156
Real m_interpolatorDistanceRemain
Definition: chanalyzer.h:179
fftfilt::cmplx m_sum
Definition: chanalyzer.h:169
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: chanalyzer.cpp:236
static const QString m_channelId
Definition: chanalyzer.h:158
fftcorr * m_corr
Definition: chanalyzer.h:184
PhaseLockComplex m_pll
Definition: chanalyzer.h:175
void applySettings(const ChannelAnalyzerSettings &settings, bool force=false)
Definition: chanalyzer.cpp:297
bool m_useInterpolator
Definition: chanalyzer.h:172
ChannelAPI(const QString &name, StreamType streamType)
Definition: channelapi.cpp:23
int m_inputFrequencyOffset
Definition: chanalyzer.h:167
Exposes a single sink stream (input, Rx)
Definition: channelapi.h:41
BasebandSampleSink * m_sampleSink
Definition: chanalyzer.h:186
DeviceAPI * m_deviceAPI
Definition: chanalyzer.h:161
void addChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Add a channel sink (Rx)
Definition: deviceapi.cpp:118
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: chanalyzer.h:162
QMutex m_settingsMutex
Definition: chanalyzer.h:189
Real m_interpolatorDistance
Definition: chanalyzer.h:178
fftfilt * RRCFilter
Definition: chanalyzer.h:183
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
void computeCoefficients(Real wn, Real zeta, Real K)
int m_undersampleCount
Definition: chanalyzer.h:168
static const QString m_channelIdURI
Definition: chanalyzer.h:157
fftfilt * SSBFilter
Definition: chanalyzer.h:181
#define ssbFftLen
Definition: chanalyzer.h:38
fftfilt * DSBFilter
Definition: chanalyzer.h:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~ChannelAnalyzer()

ChannelAnalyzer::~ChannelAnalyzer ( )
virtual

Definition at line 67 of file chanalyzer.cpp.

References DSBFilter, m_channelizer, m_deviceAPI, m_threadedChannelizer, DeviceAPI::removeChannelSink(), DeviceAPI::removeChannelSinkAPI(), RRCFilter, and SSBFilter.

Referenced by ChannelAnalyzer::MsgReportChannelSampleRateChanged::MsgReportChannelSampleRateChanged().

68 {
71  delete m_threadedChannelizer;
72  delete m_channelizer;
73  delete SSBFilter;
74  delete DSBFilter;
75  delete RRCFilter;
76 }
DownChannelizer * m_channelizer
Definition: chanalyzer.h:163
void removeChannelSinkAPI(ChannelAPI *channelAPI, int streamIndex=0)
Definition: deviceapi.cpp:163
void removeChannelSink(ThreadedBasebandSampleSink *sink, int streamIndex=0)
Remove a channel sink (Rx)
Definition: deviceapi.cpp:127
DeviceAPI * m_deviceAPI
Definition: chanalyzer.h:161
ThreadedBasebandSampleSink * m_threadedChannelizer
Definition: chanalyzer.h:162
fftfilt * RRCFilter
Definition: chanalyzer.h:183
fftfilt * SSBFilter
Definition: chanalyzer.h:181
fftfilt * DSBFilter
Definition: chanalyzer.h:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applyChannelSettings()

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

Definition at line 236 of file chanalyzer.cpp.

References Interpolator::create(), ChannelAnalyzerSettings::m_bandwidth, ChannelAnalyzerSettings::m_downSample, ChannelAnalyzerSettings::m_downSampleRate, m_fll, m_inputFrequencyOffset, m_inputSampleRate, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, ChannelAnalyzerSettings::m_lowCutoff, m_nco, m_pll, m_settings, m_settingsMutex, ChannelAnalyzerSettings::m_spanLog2, setFilters(), NCOF::setFreq(), FreqLockComplex::setSampleRate(), and PhaseLockComplex::setSampleRate().

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

237 {
238  qDebug() << "ChannelAnalyzer::applyChannelSettings:"
239  << " inputSampleRate: " << inputSampleRate
240  << " inputFrequencyOffset: " << inputFrequencyOffset;
241 
242  if ((m_inputFrequencyOffset != inputFrequencyOffset) ||
243  (m_inputSampleRate != inputSampleRate) || force)
244  {
245  m_nco.setFreq(-inputFrequencyOffset, inputSampleRate);
246  }
247 
248  if ((m_inputSampleRate != inputSampleRate) || force)
249  {
250  m_settingsMutex.lock();
251 
252  m_interpolator.create(16, inputSampleRate, inputSampleRate / 2.2f);
255 
257  {
259  m_pll.setSampleRate(inputSampleRate / (1<<m_settings.m_spanLog2));
260  m_fll.setSampleRate(inputSampleRate / (1<<m_settings.m_spanLog2));
261  }
262 
263  m_settingsMutex.unlock();
264  }
265 
266  m_inputSampleRate = inputSampleRate;
267  m_inputFrequencyOffset = inputFrequencyOffset;
268 }
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
Real m_interpolatorDistanceRemain
Definition: chanalyzer.h:179
PhaseLockComplex m_pll
Definition: chanalyzer.h:175
int m_inputFrequencyOffset
Definition: chanalyzer.h:167
Interpolator m_interpolator
Definition: chanalyzer.h:177
QMutex m_settingsMutex
Definition: chanalyzer.h:189
FreqLockComplex m_fll
Definition: chanalyzer.h:176
void setFreq(Real freq, Real sampleRate)
Definition: ncof.cpp:51
Real m_interpolatorDistance
Definition: chanalyzer.h:178
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
float Real
Definition: dsptypes.h:42
void setSampleRate(unsigned int sampleRate)
void setSampleRate(unsigned int sampleRate)
void setFilters(int sampleRate, float bandwidth, float lowCutoff)
Definition: chanalyzer.cpp:270
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySettings()

void ChannelAnalyzer::applySettings ( const ChannelAnalyzerSettings settings,
bool  force = false 
)
private

Definition at line 297 of file chanalyzer.cpp.

References Interpolator::create(), fftfilt::create_rrc_filter(), ChannelAnalyzerSettings::m_bandwidth, ChannelAnalyzerSettings::m_downSample, ChannelAnalyzerSettings::m_downSampleRate, ChannelAnalyzerSettings::m_fll, m_fll, m_inputSampleRate, ChannelAnalyzerSettings::m_inputType, m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, ChannelAnalyzerSettings::m_lowCutoff, ChannelAnalyzerSettings::m_pll, m_pll, ChannelAnalyzerSettings::m_pllPskOrder, ChannelAnalyzerSettings::m_rrc, ChannelAnalyzerSettings::m_rrcRolloff, m_settings, m_settingsMutex, ChannelAnalyzerSettings::m_spanLog2, ChannelAnalyzerSettings::m_ssb, m_useInterpolator, FreqLockComplex::reset(), PhaseLockComplex::reset(), RRCFilter, setFilters(), PhaseLockComplex::setPskOrder(), FreqLockComplex::setSampleRate(), and PhaseLockComplex::setSampleRate().

Referenced by ChannelAnalyzer(), and handleMessage().

298 {
299  qDebug() << "ChannelAnalyzer::applySettings:"
300  << " m_downSample: " << settings.m_downSample
301  << " m_downSampleRate: " << settings.m_downSampleRate
302  << " m_rcc: " << settings.m_rrc
303  << " m_rrcRolloff: " << settings.m_rrcRolloff / 100.0
304  << " m_bandwidth: " << settings.m_bandwidth
305  << " m_lowCutoff: " << settings.m_lowCutoff
306  << " m_spanLog2: " << settings.m_spanLog2
307  << " m_ssb: " << settings.m_ssb
308  << " m_pll: " << settings.m_pll
309  << " m_fll: " << settings.m_fll
310  << " m_pllPskOrder: " << settings.m_pllPskOrder
311  << " m_inputType: " << (int) settings.m_inputType;
312 
313  if ((settings.m_downSampleRate != m_settings.m_downSampleRate) || force)
314  {
315  m_settingsMutex.lock();
319  m_settingsMutex.unlock();
320  }
321 
322  if ((settings.m_downSample != m_settings.m_downSample) || force)
323  {
324  int sampleRate = settings.m_downSample ? settings.m_downSampleRate : m_inputSampleRate;
325 
326  m_settingsMutex.lock();
327  m_useInterpolator = settings.m_downSample;
328  setFilters(sampleRate, settings.m_bandwidth, settings.m_lowCutoff);
329  m_pll.setSampleRate(sampleRate / (1<<settings.m_spanLog2));
330  m_fll.setSampleRate(sampleRate / (1<<settings.m_spanLog2));
331  m_settingsMutex.unlock();
332  }
333 
334  if ((settings.m_bandwidth != m_settings.m_bandwidth) ||
335  (settings.m_lowCutoff != m_settings.m_lowCutoff)|| force)
336  {
337  m_settingsMutex.lock();
338  setFilters(settings.m_downSample ? settings.m_downSampleRate : m_inputSampleRate, settings.m_bandwidth, settings.m_lowCutoff);
339  m_settingsMutex.unlock();
340  }
341 
342  if ((settings.m_rrcRolloff != m_settings.m_rrcRolloff) || force)
343  {
344  float sampleRate = settings.m_downSample ? (float) settings.m_downSampleRate : (float) m_inputSampleRate;
345  m_settingsMutex.lock();
346  RRCFilter->create_rrc_filter(settings.m_bandwidth / sampleRate, settings.m_rrcRolloff / 100.0);
347  m_settingsMutex.unlock();
348  }
349 
350  if ((settings.m_spanLog2 != m_settings.m_spanLog2) || force)
351  {
352  int sampleRate = (settings.m_downSample ? settings.m_downSampleRate : m_inputSampleRate) / (1<<m_settings.m_spanLog2);
353  m_pll.setSampleRate(sampleRate);
354  m_fll.setSampleRate(sampleRate);
355  }
356 
357  if (settings.m_pll != m_settings.m_pll || force)
358  {
359  if (settings.m_pll)
360  {
361  m_pll.reset();
362  m_fll.reset();
363  }
364  }
365 
366  if (settings.m_fll != m_settings.m_fll || force)
367  {
368  if (settings.m_fll) {
369  m_fll.reset();
370  }
371  }
372 
373  if (settings.m_pllPskOrder != m_settings.m_pllPskOrder || force)
374  {
375  if (settings.m_pllPskOrder < 32) {
376  m_pll.setPskOrder(settings.m_pllPskOrder);
377  }
378  }
379 
380  m_settings = settings;
381 }
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
Real m_interpolatorDistanceRemain
Definition: chanalyzer.h:179
PhaseLockComplex m_pll
Definition: chanalyzer.h:175
quint32 m_rrcRolloff
in 100ths
bool m_useInterpolator
Definition: chanalyzer.h:172
Interpolator m_interpolator
Definition: chanalyzer.h:177
void create_rrc_filter(float fb, float a)
root raised cosine. fb is half the band pass
Definition: fftfilt.cpp:222
QMutex m_settingsMutex
Definition: chanalyzer.h:189
FreqLockComplex m_fll
Definition: chanalyzer.h:176
Real m_interpolatorDistance
Definition: chanalyzer.h:178
fftfilt * RRCFilter
Definition: chanalyzer.h:183
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
void setPskOrder(unsigned int order)
float Real
Definition: dsptypes.h:42
void setSampleRate(unsigned int sampleRate)
void setSampleRate(unsigned int sampleRate)
void setFilters(int sampleRate, float bandwidth, float lowCutoff)
Definition: chanalyzer.cpp:270
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

virtual bool ChannelAnalyzer::deserialize ( const QByteArray &  data)
inlinevirtual

Implements ChannelAPI.

Definition at line 145 of file chanalyzer.h.

145 { (void) data; return false; }

◆ destroy()

virtual void ChannelAnalyzer::destroy ( )
inlinevirtual

Implements ChannelAPI.

Definition at line 111 of file chanalyzer.h.

111 { delete this; }

◆ feed()

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

Implements BasebandSampleSink.

Definition at line 78 of file chanalyzer.cpp.

References Interpolator::decimate(), BasebandSampleSink::feed(), m_interpolator, m_interpolatorDistance, m_interpolatorDistanceRemain, m_nco, m_sampleBuffer, m_sampleSink, m_settings, m_settingsMutex, ChannelAnalyzerSettings::m_ssb, m_useInterpolator, NCOF::nextIQ(), and processOneSample().

Referenced by getPllPhase().

79 {
80  (void) positiveOnly;
81  fftfilt::cmplx *sideband = 0;
82  Complex ci;
83 
84  m_settingsMutex.lock();
85 
86  for(SampleVector::const_iterator it = begin; it < end; ++it)
87  {
88  Complex c(it->real(), it->imag());
89  c *= m_nco.nextIQ();
90 
92  {
94  {
95  processOneSample(ci, sideband);
97  }
98  }
99  else
100  {
101  processOneSample(c, sideband);
102  }
103  }
104 
105  if(m_sampleSink != 0)
106  {
107  m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), m_settings.m_ssb); // m_ssb = positive only
108  }
109 
110  m_sampleBuffer.clear();
111 
112  m_settingsMutex.unlock();
113 }
bool decimate(Real *distance, const Complex &next, Complex *result)
Definition: interpolator.h:38
Real m_interpolatorDistanceRemain
Definition: chanalyzer.h:179
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
SampleVector m_sampleBuffer
Definition: chanalyzer.h:187
bool m_useInterpolator
Definition: chanalyzer.h:172
Interpolator m_interpolator
Definition: chanalyzer.h:177
void processOneSample(Complex &c, fftfilt::cmplx *sideband)
Definition: chanalyzer.cpp:115
BasebandSampleSink * m_sampleSink
Definition: chanalyzer.h:186
QMutex m_settingsMutex
Definition: chanalyzer.h:189
Real m_interpolatorDistance
Definition: chanalyzer.h:178
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
std::complex< Real > Complex
Definition: dsptypes.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ feedOneSample()

void ChannelAnalyzer::feedOneSample ( const fftfilt::cmplx s,
const fftfilt::cmplx pll 
)
inlineprivate

Definition at line 197 of file chanalyzer.h.

References ChannelAnalyzerSettings::InputAutoCorr, ChannelAnalyzerSettings::InputPLL, ChannelAnalyzerSettings::InputSignal, ChannelAnalyzerSettings::m_inputType, ChannelAnalyzerSettings::m_ssb, fftcorr::run(), and SDR_RX_SCALEF.

Referenced by processOneSample().

198  {
199  switch (m_settings.m_inputType)
200  {
202  {
203  if (m_settings.m_ssb & !m_usb) { // invert spectrum for LSB
204  m_sampleBuffer.push_back(Sample(pll.imag()*SDR_RX_SCALEF, pll.real()*SDR_RX_SCALEF));
205  } else {
206  m_sampleBuffer.push_back(Sample(pll.real()*SDR_RX_SCALEF, pll.imag()*SDR_RX_SCALEF));
207  }
208  }
209  break;
211  {
212  std::complex<float> a = m_corr->run(s/(SDR_RX_SCALEF/768.0f), 0);
213 
214  if (m_settings.m_ssb & !m_usb) { // invert spectrum for LSB
215  m_sampleBuffer.push_back(Sample(a.imag(), a.real()));
216  } else {
217  m_sampleBuffer.push_back(Sample(a.real(), a.imag()));
218  }
219  }
220  break;
222  default:
223  {
224  if (m_settings.m_ssb & !m_usb) { // invert spectrum for LSB
225  m_sampleBuffer.push_back(Sample(s.imag(), s.real()));
226  } else {
227  m_sampleBuffer.push_back(Sample(s.real(), s.imag()));
228  }
229  }
230  break;
231  }
232  }
SampleVector m_sampleBuffer
Definition: chanalyzer.h:187
#define SDR_RX_SCALEF
Definition: dsptypes.h:33
fftcorr * m_corr
Definition: chanalyzer.h:184
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
int run(const cmplx &inA, const cmplx *inB, cmplx **out)
if inB = 0 then run auto-correlation
Definition: fftcorr.cpp:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCenterFrequency()

virtual qint64 ChannelAnalyzer::getCenterFrequency ( ) const
inlinevirtual

Applies to a default stream.

Implements ChannelAPI.

Definition at line 142 of file chanalyzer.h.

References ChannelAnalyzerSettings::m_frequency, and ChannelAnalyzer::MsgConfigureChannelAnalyzer::m_settings.

142 { return m_settings.m_frequency; }
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164

◆ getChannelizer()

DownChannelizer* ChannelAnalyzer::getChannelizer ( )
inline

Definition at line 124 of file chanalyzer.h.

References m_channelizer.

Referenced by ChannelAnalyzerGUI::getRequestedChannelSampleRate().

124 { return m_channelizer; }
DownChannelizer * m_channelizer
Definition: chanalyzer.h:163
+ Here is the caller graph for this function:

◆ getChannelSampleRate()

int ChannelAnalyzer::getChannelSampleRate ( ) const
inline

◆ getDecimation()

int ChannelAnalyzer::getDecimation ( ) const
inline

Definition at line 127 of file chanalyzer.h.

References ChannelAnalyzer::MsgConfigureChannelAnalyzer::m_settings, and ChannelAnalyzerSettings::m_spanLog2.

Referenced by ChannelAnalyzerGUI::tick().

127 { return 1<<m_settings.m_spanLog2; }
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
+ Here is the caller graph for this function:

◆ getIdentifier()

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

Implements ChannelAPI.

Definition at line 140 of file chanalyzer.h.

140 { id = objectName(); }

◆ getInputSampleRate()

int ChannelAnalyzer::getInputSampleRate ( ) const
inline

Definition at line 125 of file chanalyzer.h.

References m_inputSampleRate.

Referenced by ChannelAnalyzerGUI::displaySettings(), and ChannelAnalyzerGUI::handleMessage().

125 { return m_inputSampleRate; }
+ Here is the caller graph for this function:

◆ getMagSq()

double ChannelAnalyzer::getMagSq ( ) const
inline

Definition at line 128 of file chanalyzer.h.

References m_magsq.

128 { return m_magsq; }

◆ getMagSqAvg()

double ChannelAnalyzer::getMagSqAvg ( ) const
inline

Definition at line 129 of file chanalyzer.h.

References m_channelPowerAvg.

Referenced by ChannelAnalyzerGUI::tick().

129 { return (double) m_channelPowerAvg; }
MovingAverageUtil< double, double, 480 > m_channelPowerAvg
Definition: chanalyzer.h:188
+ Here is the caller graph for this function:

◆ getNbSinkStreams()

virtual int ChannelAnalyzer::getNbSinkStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 147 of file chanalyzer.h.

147 { return 1; }

◆ getNbSourceStreams()

virtual int ChannelAnalyzer::getNbSourceStreams ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 148 of file chanalyzer.h.

148 { return 0; }

◆ getPllDeltaPhase()

Real ChannelAnalyzer::getPllDeltaPhase ( ) const
inline

Definition at line 132 of file chanalyzer.h.

References PhaseLockComplex::getDeltaPhi(), and m_pll.

132 { return m_pll.getDeltaPhi(); }
float getDeltaPhi() const
PhaseLockComplex m_pll
Definition: chanalyzer.h:175
+ Here is the call graph for this function:

◆ getPllFrequency()

Real ChannelAnalyzer::getPllFrequency ( ) const

Definition at line 383 of file chanalyzer.cpp.

References FreqLockComplex::getFreq(), PhaseLockComplex::getFreq(), ChannelAnalyzerSettings::m_fll, m_fll, ChannelAnalyzerSettings::m_pll, m_pll, and m_settings.

Referenced by isPllLocked(), and ChannelAnalyzerGUI::tick().

384 {
385  if (m_settings.m_fll) {
386  return m_fll.getFreq();
387  } else if (m_settings.m_pll) {
388  return m_pll.getFreq();
389  } else {
390  return 0.0;
391  }
392 }
float getFreq() const
float getFreq() const
PhaseLockComplex m_pll
Definition: chanalyzer.h:175
FreqLockComplex m_fll
Definition: chanalyzer.h:176
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPllPhase()

Real ChannelAnalyzer::getPllPhase ( ) const
inline

Definition at line 133 of file chanalyzer.h.

References feed(), PhaseLockComplex::getPhiHat(), handleMessage(), m_pll, start(), and stop().

133 { return m_pll.getPhiHat(); }
float getPhiHat() const
PhaseLockComplex m_pll
Definition: chanalyzer.h:175
+ Here is the call graph for this function:

◆ getStreamCenterFrequency()

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

Implements ChannelAPI.

Definition at line 150 of file chanalyzer.h.

References ChannelAnalyzerSettings::m_frequency, and ChannelAnalyzer::MsgConfigureChannelAnalyzer::m_settings.

151  {
152  (void) streamIndex;
153  (void) sinkElseSource;
154  return m_settings.m_frequency;
155  }
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164

◆ getTitle()

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

Implements ChannelAPI.

Definition at line 141 of file chanalyzer.h.

141 { title = objectName(); }

◆ handleMessage()

bool ChannelAnalyzer::handleMessage ( const Message cmd)
virtual

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

Implements BasebandSampleSink.

Definition at line 180 of file chanalyzer.cpp.

References applyChannelSettings(), applySettings(), DownChannelizer::configure(), ChannelAnalyzer::MsgReportChannelSampleRateChanged::create(), ChannelAnalyzer::MsgConfigureChannelizer::getCenterFrequency(), ChannelAnalyzer::MsgConfigureChannelAnalyzer::getForce(), DownChannelizer::MsgChannelizerNotification::getFrequencyOffset(), BasebandSampleSink::getInputMessageQueue(), BasebandSampleSink::getMessageQueueToGUI(), DownChannelizer::MsgChannelizerNotification::getSampleRate(), ChannelAnalyzer::MsgConfigureChannelizer::getSampleRate(), ChannelAnalyzer::MsgConfigureChannelAnalyzer::getSettings(), m_channelizer, Message::match(), and MessageQueue::push().

Referenced by getPllPhase().

181 {
183  {
185  qDebug() << "ChannelAnalyzer::handleMessage: DownChannelizer::MsgChannelizerNotification:"
186  << " sampleRate: " << notif.getSampleRate()
187  << " frequencyOffset: " << notif.getFrequencyOffset();
188 
190 
191  if (getMessageQueueToGUI())
192  {
193  MsgReportChannelSampleRateChanged *msg = MsgReportChannelSampleRateChanged::create();
194  getMessageQueueToGUI()->push(msg);
195  }
196 
197  return true;
198  }
199  else if (MsgConfigureChannelizer::match(cmd))
200  {
201  MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
202  qDebug() << "ChannelAnalyzer::handleMessage: MsgConfigureChannelizer:"
203  << " sampleRate: " << cfg.getSampleRate()
204  << " centerFrequency: " << cfg.getCenterFrequency();
205 
207  cfg.getSampleRate(),
208  cfg.getCenterFrequency());
209 
210  return true;
211  }
213  {
214  qDebug("ChannelAnalyzer::handleMessage: MsgConfigureChannelAnalyzer");
215  MsgConfigureChannelAnalyzer& cfg = (MsgConfigureChannelAnalyzer&) cmd;
216 
217  applySettings(cfg.getSettings(), cfg.getForce());
218 
219  return true;
220  }
221  else
222  {
223  // Processed through GUI
224 // if (m_sampleSink != 0)
225 // {
226 // return m_sampleSink->handleMessage(cmd);
227 // }
228 // else
229 // {
230 // return false;
231 // }
232  return false;
233  }
234 }
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
DownChannelizer * m_channelizer
Definition: chanalyzer.h:163
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: chanalyzer.cpp:236
static MsgReportChannelSampleRateChanged * create()
Definition: chanalyzer.h:97
void applySettings(const ChannelAnalyzerSettings &settings, bool force=false)
Definition: chanalyzer.cpp:297
static bool match(const Message *message)
Definition: message.cpp:45
MessageQueue * getMessageQueueToGUI()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isPllLocked()

bool ChannelAnalyzer::isPllLocked ( ) const
inline

Definition at line 130 of file chanalyzer.h.

References getPllFrequency(), PhaseLockComplex::locked(), ChannelAnalyzerSettings::m_pll, m_pll, and ChannelAnalyzer::MsgConfigureChannelAnalyzer::m_settings.

Referenced by ChannelAnalyzerGUI::tick().

130 { return m_settings.m_pll && m_pll.locked(); }
PhaseLockComplex m_pll
Definition: chanalyzer.h:175
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
bool locked() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processOneSample()

void ChannelAnalyzer::processOneSample ( Complex c,
fftfilt::cmplx sideband 
)
private

Definition at line 115 of file chanalyzer.cpp.

References DSBFilter, FreqLockComplex::feed(), PhaseLockComplex::feed(), feedOneSample(), FreqLockComplex::getComplex(), PhaseLockComplex::getComplex(), i, m_channelPowerAvg, ChannelAnalyzerSettings::m_fll, m_fll, m_magsq, ChannelAnalyzerSettings::m_pll, m_pll, ChannelAnalyzerSettings::m_rrc, m_settings, ChannelAnalyzerSettings::m_spanLog2, ChannelAnalyzerSettings::m_ssb, m_sum, m_undersampleCount, m_usb, RRCFilter, fftfilt::runDSB(), fftfilt::runFilt(), fftfilt::runSSB(), SDR_RX_SCALEF, and SSBFilter.

Referenced by feed().

116 {
117  int n_out;
118  int decim = 1<<m_settings.m_spanLog2;
119 
120  if (m_settings.m_ssb)
121  {
122  n_out = SSBFilter->runSSB(c, &sideband, m_usb);
123  }
124  else
125  {
126  if (m_settings.m_rrc) {
127  n_out = RRCFilter->runFilt(c, &sideband);
128  } else {
129  n_out = DSBFilter->runDSB(c, &sideband);
130  }
131  }
132 
133  for (int i = 0; i < n_out; i++)
134  {
135  // Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
136  // smart decimation with bit gain using float arithmetic (23 bits significand)
137 
138  m_sum += sideband[i];
139 
140  if (!(m_undersampleCount++ & (decim - 1))) // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
141  {
142  m_sum /= decim;
143  Real re = m_sum.real() / SDR_RX_SCALEF;
144  Real im = m_sum.imag() / SDR_RX_SCALEF;
145  m_magsq = re*re + im*im;
147  std::complex<float> mix;
148 
149  if (m_settings.m_pll)
150  {
151  if (m_settings.m_fll)
152  {
153  m_fll.feed(re, im);
154  // Use -fPLL to mix (exchange PLL real and image in the complex multiplication)
155  mix = m_sum * std::conj(m_fll.getComplex());
156  }
157  else
158  {
159  m_pll.feed(re, im);
160  // Use -fPLL to mix (exchange PLL real and image in the complex multiplication)
161  mix = m_sum * std::conj(m_pll.getComplex());
162  }
163  }
164 
166  m_sum = 0;
167  }
168  }
169 }
MovingAverageUtil< double, double, 480 > m_channelPowerAvg
Definition: chanalyzer.h:188
int runFilt(const cmplx &in, cmplx **out)
Definition: fftfilt.cpp:260
fftfilt::cmplx m_sum
Definition: chanalyzer.h:169
#define SDR_RX_SCALEF
Definition: dsptypes.h:33
const std::complex< float > & getComplex() const
PhaseLockComplex m_pll
Definition: chanalyzer.h:175
int32_t i
Definition: decimators.h:244
void feedOneSample(const fftfilt::cmplx &s, const fftfilt::cmplx &pll)
Definition: chanalyzer.h:197
const std::complex< float > & getComplex() const
int runSSB(const cmplx &in, cmplx **out, bool usb, bool getDC=true)
Definition: fftfilt.cpp:284
FreqLockComplex m_fll
Definition: chanalyzer.h:176
void feed(float re, float im)
fftfilt * RRCFilter
Definition: chanalyzer.h:183
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
int m_undersampleCount
Definition: chanalyzer.h:168
int runDSB(const cmplx &in, cmplx **out, bool getDC=true)
Definition: fftfilt.cpp:327
float Real
Definition: dsptypes.h:42
void feed(float re, float im)
fftfilt * SSBFilter
Definition: chanalyzer.h:181
fftfilt * DSBFilter
Definition: chanalyzer.h:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

virtual QByteArray ChannelAnalyzer::serialize ( ) const
inlinevirtual

Implements ChannelAPI.

Definition at line 144 of file chanalyzer.h.

144 { return QByteArray(); }

◆ setFilters()

void ChannelAnalyzer::setFilters ( int  sampleRate,
float  bandwidth,
float  lowCutoff 
)
private

Definition at line 270 of file chanalyzer.cpp.

References fftfilt::create_dsb_filter(), fftfilt::create_filter(), fftfilt::create_rrc_filter(), DSBFilter, ChannelAnalyzerSettings::m_rrcRolloff, m_settings, m_usb, RRCFilter, and SSBFilter.

Referenced by applyChannelSettings(), and applySettings().

271 {
272  qDebug("ChannelAnalyzer::setFilters: sampleRate: %d bandwidth: %f lowCutoff: %f",
273  sampleRate, bandwidth, lowCutoff);
274 
275  if (bandwidth < 0)
276  {
277  bandwidth = -bandwidth;
278  lowCutoff = -lowCutoff;
279  m_usb = false;
280  }
281  else
282  {
283  m_usb = true;
284  }
285 
286  if (bandwidth < 100.0f)
287  {
288  bandwidth = 100.0f;
289  lowCutoff = 0;
290  }
291 
292  SSBFilter->create_filter(lowCutoff / sampleRate, bandwidth / sampleRate);
293  DSBFilter->create_dsb_filter(bandwidth / sampleRate);
294  RRCFilter->create_rrc_filter(bandwidth / sampleRate, m_settings.m_rrcRolloff / 100.0);
295 }
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
quint32 m_rrcRolloff
in 100ths
void create_rrc_filter(float fb, float a)
root raised cosine. fb is half the band pass
Definition: fftfilt.cpp:222
fftfilt * RRCFilter
Definition: chanalyzer.h:183
ChannelAnalyzerSettings m_settings
Definition: chanalyzer.h:164
fftfilt * SSBFilter
Definition: chanalyzer.h:181
void create_dsb_filter(float f2)
Definition: fftfilt.cpp:148
fftfilt * DSBFilter
Definition: chanalyzer.h:182
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSampleSink()

void ChannelAnalyzer::setSampleSink ( BasebandSampleSink sampleSink)
inline

Definition at line 112 of file chanalyzer.h.

References m_sampleSink.

Referenced by ChannelAnalyzerGUI::ChannelAnalyzerGUI().

112 { m_sampleSink = sampleSink; }
BasebandSampleSink * m_sampleSink
Definition: chanalyzer.h:186
+ Here is the caller graph for this function:

◆ start()

void ChannelAnalyzer::start ( )
virtual

Implements BasebandSampleSink.

Definition at line 171 of file chanalyzer.cpp.

References applyChannelSettings(), m_inputFrequencyOffset, and m_inputSampleRate.

Referenced by getPllPhase().

172 {
174 }
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force=false)
Definition: chanalyzer.cpp:236
int m_inputFrequencyOffset
Definition: chanalyzer.h:167
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void ChannelAnalyzer::stop ( )
virtual

Implements BasebandSampleSink.

Definition at line 176 of file chanalyzer.cpp.

Referenced by getPllPhase().

177 {
178 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ DSBFilter

fftfilt* ChannelAnalyzer::DSBFilter
private

Definition at line 182 of file chanalyzer.h.

Referenced by ChannelAnalyzer(), processOneSample(), setFilters(), and ~ChannelAnalyzer().

◆ m_channelId

const QString ChannelAnalyzer::m_channelId = "ChannelAnalyzer"
static

Definition at line 158 of file chanalyzer.h.

Referenced by ChannelAnalyzer(), and ChannelAnalyzerPlugin::initPlugin().

◆ m_channelIdURI

const QString ChannelAnalyzer::m_channelIdURI = "sdrangel.channel.chanalyzer"
static

◆ m_channelizer

DownChannelizer* ChannelAnalyzer::m_channelizer
private

Definition at line 163 of file chanalyzer.h.

Referenced by ChannelAnalyzer(), getChannelizer(), handleMessage(), and ~ChannelAnalyzer().

◆ m_channelPowerAvg

MovingAverageUtil<double, double, 480> ChannelAnalyzer::m_channelPowerAvg
private

Definition at line 188 of file chanalyzer.h.

Referenced by getMagSqAvg(), and processOneSample().

◆ m_corr

fftcorr* ChannelAnalyzer::m_corr
private

Definition at line 184 of file chanalyzer.h.

Referenced by ChannelAnalyzer().

◆ m_deviceAPI

DeviceAPI* ChannelAnalyzer::m_deviceAPI
private

Definition at line 161 of file chanalyzer.h.

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

◆ m_fll

FreqLockComplex ChannelAnalyzer::m_fll
private

◆ m_inputFrequencyOffset

int ChannelAnalyzer::m_inputFrequencyOffset
private

Definition at line 167 of file chanalyzer.h.

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

◆ m_inputSampleRate

int ChannelAnalyzer::m_inputSampleRate
private

◆ m_interpolator

Interpolator ChannelAnalyzer::m_interpolator
private

Definition at line 177 of file chanalyzer.h.

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

◆ m_interpolatorDistance

Real ChannelAnalyzer::m_interpolatorDistance
private

Definition at line 178 of file chanalyzer.h.

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

◆ m_interpolatorDistanceRemain

Real ChannelAnalyzer::m_interpolatorDistanceRemain
private

Definition at line 179 of file chanalyzer.h.

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

◆ m_magsq

double ChannelAnalyzer::m_magsq
private

Definition at line 171 of file chanalyzer.h.

Referenced by ChannelAnalyzer(), getMagSq(), and processOneSample().

◆ m_nco

NCOF ChannelAnalyzer::m_nco
private

Definition at line 174 of file chanalyzer.h.

Referenced by applyChannelSettings(), and feed().

◆ m_pll

PhaseLockComplex ChannelAnalyzer::m_pll
private

◆ m_sampleBuffer

SampleVector ChannelAnalyzer::m_sampleBuffer
private

Definition at line 187 of file chanalyzer.h.

Referenced by feed().

◆ m_sampleSink

BasebandSampleSink* ChannelAnalyzer::m_sampleSink
private

Definition at line 186 of file chanalyzer.h.

Referenced by feed(), and setSampleSink().

◆ m_settings

ChannelAnalyzerSettings ChannelAnalyzer::m_settings
private

◆ m_settingsMutex

QMutex ChannelAnalyzer::m_settingsMutex
private

Definition at line 189 of file chanalyzer.h.

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

◆ m_sum

fftfilt::cmplx ChannelAnalyzer::m_sum
private

Definition at line 169 of file chanalyzer.h.

Referenced by ChannelAnalyzer(), and processOneSample().

◆ m_threadedChannelizer

ThreadedBasebandSampleSink* ChannelAnalyzer::m_threadedChannelizer
private

Definition at line 162 of file chanalyzer.h.

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

◆ m_undersampleCount

int ChannelAnalyzer::m_undersampleCount
private

Definition at line 168 of file chanalyzer.h.

Referenced by ChannelAnalyzer(), and processOneSample().

◆ m_usb

bool ChannelAnalyzer::m_usb
private

Definition at line 170 of file chanalyzer.h.

Referenced by ChannelAnalyzer(), processOneSample(), and setFilters().

◆ m_useInterpolator

bool ChannelAnalyzer::m_useInterpolator
private

Definition at line 172 of file chanalyzer.h.

Referenced by applySettings(), ChannelAnalyzer(), and feed().

◆ RRCFilter

fftfilt* ChannelAnalyzer::RRCFilter
private

◆ SSBFilter

fftfilt* ChannelAnalyzer::SSBFilter
private

Definition at line 181 of file chanalyzer.h.

Referenced by ChannelAnalyzer(), processOneSample(), setFilters(), and ~ChannelAnalyzer().


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