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.
Public Member Functions | Public Attributes | Private Attributes | List of all members
leansdr::ss_amp_estimator< T > Struct Template Reference

#include <sdr.h>

+ Inheritance diagram for leansdr::ss_amp_estimator< T >:
+ Collaboration diagram for leansdr::ss_amp_estimator< T >:

Public Member Functions

 ss_amp_estimator (scheduler *sch, pipebuf< complex< T >> &_in, pipebuf< T > &_out_ss, pipebuf< T > &_out_ampmin, pipebuf< T > &_out_ampmax)
 
void run ()
 
- Public Member Functions inherited from leansdr::runnable
 runnable (scheduler *_sch, const char *name)
 
- Public Member Functions inherited from leansdr::runnable_common
 runnable_common (const char *_name)
 
virtual ~runnable_common ()
 
virtual void shutdown ()
 

Public Attributes

unsigned long window_size
 
unsigned long decimation
 
- Public Attributes inherited from leansdr::runnable_common
const char * name
 

Private Attributes

pipereader< complex< T > > in
 
pipewriter< T > out_ss
 
pipewriter< T > out_ampmin
 
pipewriter< T > out_ampmax
 
unsigned long phase
 

Additional Inherited Members

- Protected Attributes inherited from leansdr::runnable
schedulersch
 

Detailed Description

template<typename T>
struct leansdr::ss_amp_estimator< T >

Definition at line 266 of file sdr.h.

Constructor & Destructor Documentation

◆ ss_amp_estimator()

template<typename T >
leansdr::ss_amp_estimator< T >::ss_amp_estimator ( scheduler sch,
pipebuf< complex< T >> &  _in,
pipebuf< T > &  _out_ss,
pipebuf< T > &  _out_ampmin,
pipebuf< T > &  _out_ampmax 
)
inline

Definition at line 271 of file sdr.h.

275  : runnable(sch, "SS estimator"),
276  window_size(1024),
277  decimation(1024),
278  in(_in),
279  out_ss(_out_ss),
280  out_ampmin(_out_ampmin),
281  out_ampmax(_out_ampmax),
282  phase(0)
283  {
284  }
pipereader< complex< T > > in
Definition: sdr.h:320
unsigned long decimation
Definition: sdr.h:269
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
pipewriter< T > out_ampmax
Definition: sdr.h:321
unsigned long window_size
Definition: sdr.h:268
pipewriter< T > out_ss
Definition: sdr.h:321
pipewriter< T > out_ampmin
Definition: sdr.h:321
scheduler * sch
Definition: framework.h:199
unsigned long phase
Definition: sdr.h:322

Member Function Documentation

◆ run()

template<typename T >
void leansdr::ss_amp_estimator< T >::run ( )
inlinevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 286 of file sdr.h.

References leansdr::auto_notch< T >::decimation, leansdr::complex< T >::im, leansdr::auto_notch< T >::in, leansdr::auto_notch< T >::phase, and leansdr::complex< T >::re.

287  {
288  while (in.readable() >= window_size && out_ss.writable() >= 1 && out_ampmin.writable() >= 1 && out_ampmax.writable() >= 1)
289  {
290  phase += window_size;
291 
292  if (phase >= decimation)
293  {
294  phase -= decimation;
295  complex<T> *p = in.rd(), *pend = p + window_size;
296  float s2 = 0;
297  float amin = 1e38, amax = 0;
298 
299  for (; p < pend; ++p)
300  {
301  float mag2 = (float)p->re * p->re + (float)p->im * p->im;
302  s2 += mag2;
303  float mag = sqrtf(mag2);
304  if (mag < amin)
305  amin = mag;
306  if (mag > amax)
307  amax = mag;
308  }
309 
310  out_ss.write(sqrtf(s2 / window_size));
311  out_ampmin.write(amin);
312  out_ampmax.write(amax);
313  }
314 
315  in.read(window_size);
316  }
317  }
pipereader< complex< T > > in
Definition: sdr.h:320
unsigned long decimation
Definition: sdr.h:269
pipewriter< T > out_ampmax
Definition: sdr.h:321
unsigned long window_size
Definition: sdr.h:268
pipewriter< T > out_ss
Definition: sdr.h:321
pipewriter< T > out_ampmin
Definition: sdr.h:321
unsigned long phase
Definition: sdr.h:322

Member Data Documentation

◆ decimation

template<typename T >
unsigned long leansdr::ss_amp_estimator< T >::decimation

Definition at line 269 of file sdr.h.

◆ in

template<typename T >
pipereader<complex<T> > leansdr::ss_amp_estimator< T >::in
private

Definition at line 320 of file sdr.h.

◆ out_ampmax

template<typename T >
pipewriter<T> leansdr::ss_amp_estimator< T >::out_ampmax
private

Definition at line 321 of file sdr.h.

◆ out_ampmin

template<typename T >
pipewriter<T> leansdr::ss_amp_estimator< T >::out_ampmin
private

Definition at line 321 of file sdr.h.

◆ out_ss

template<typename T >
pipewriter<T> leansdr::ss_amp_estimator< T >::out_ss
private

Definition at line 321 of file sdr.h.

◆ phase

template<typename T >
unsigned long leansdr::ss_amp_estimator< T >::phase
private

Definition at line 322 of file sdr.h.

◆ window_size

template<typename T >
unsigned long leansdr::ss_amp_estimator< T >::window_size

Definition at line 268 of file sdr.h.


The documentation for this struct was generated from the following file: