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

#include <sdr.h>

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

Public Member Functions

 simple_agc (scheduler *sch, pipebuf< complex< T >> &_in, pipebuf< complex< T >> &_out)
 
- 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

float out_rms
 
float bw
 
float estimated
 
- Public Attributes inherited from leansdr::runnable_common
const char * name
 

Static Public Attributes

static const int chunk_size = 128
 

Private Member Functions

void run ()
 

Private Attributes

pipereader< complex< T > > in
 
pipewriter< complex< T > > out
 

Additional Inherited Members

- Protected Attributes inherited from leansdr::runnable
schedulersch
 

Detailed Description

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

Definition at line 328 of file sdr.h.

Constructor & Destructor Documentation

◆ simple_agc()

template<typename T >
leansdr::simple_agc< T >::simple_agc ( scheduler sch,
pipebuf< complex< T >> &  _in,
pipebuf< complex< T >> &  _out 
)
inline

Definition at line 335 of file sdr.h.

337  : runnable(sch, "AGC"),
338  out_rms(1),
339  bw(0.001),
340  estimated(0),
341  in(_in),
342  out(_out, chunk_size)
343  {
344  }
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
static const int chunk_size
Definition: sdr.h:333
float out_rms
Definition: sdr.h:330
pipereader< complex< T > > in
Definition: sdr.h:347
pipewriter< complex< T > > out
Definition: sdr.h:348
float estimated
Definition: sdr.h:332
scheduler * sch
Definition: framework.h:199

Member Function Documentation

◆ run()

template<typename T >
void leansdr::simple_agc< T >::run ( )
inlineprivatevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 350 of file sdr.h.

References leansdr::auto_notch< T >::gain, leansdr::complex< T >::im, leansdr::pipereader< T >::rd(), leansdr::complex< T >::re, leansdr::pipereader< T >::read(), leansdr::pipereader< T >::readable(), leansdr::pipewriter< T >::wr(), leansdr::pipewriter< T >::writable(), and leansdr::pipewriter< T >::written().

351  {
352  while (in.readable() >= chunk_size && out.writable() >= chunk_size)
353  {
354  complex<T> *pin = in.rd(), *pend = pin + chunk_size;
355  float amp2 = 0;
356 
357  for (; pin < pend; ++pin)
358  amp2 += pin->re * pin->re + pin->im * pin->im;
359 
360  amp2 /= chunk_size;
361 
362  if (!estimated)
363  estimated = amp2;
364 
365  estimated = estimated * (1 - bw) + amp2 * bw;
366  float gain = estimated ? out_rms / sqrtf(estimated) : 0;
367  pin = in.rd();
368  complex<T> *pout = out.wr();
369  float bwcomp = 1 - bw;
370 
371  for (; pin < pend; ++pin, ++pout)
372  {
373  pout->re = pin->re * gain;
374  pout->im = pin->im * gain;
375  }
376 
377  in.read(chunk_size);
378  out.written(chunk_size);
379  }
380  }
static const int chunk_size
Definition: sdr.h:333
float out_rms
Definition: sdr.h:330
pipereader< complex< T > > in
Definition: sdr.h:347
pipewriter< complex< T > > out
Definition: sdr.h:348
float estimated
Definition: sdr.h:332
+ Here is the call graph for this function:

Member Data Documentation

◆ bw

template<typename T >
float leansdr::simple_agc< T >::bw

Definition at line 331 of file sdr.h.

◆ chunk_size

template<typename T >
const int leansdr::simple_agc< T >::chunk_size = 128
static

Definition at line 333 of file sdr.h.

◆ estimated

template<typename T >
float leansdr::simple_agc< T >::estimated

Definition at line 332 of file sdr.h.

◆ in

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

Definition at line 347 of file sdr.h.

◆ out

template<typename T >
pipewriter<complex<T> > leansdr::simple_agc< T >::out
private

Definition at line 348 of file sdr.h.

◆ out_rms

template<typename T >
float leansdr::simple_agc< T >::out_rms

Definition at line 330 of file sdr.h.


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