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 | Private Attributes | List of all members
AutoCorrector< T > Class Template Reference

#include <autocorrector.h>

+ Collaboration diagram for AutoCorrector< T >:

Public Member Functions

 AutoCorrector (qint32 intBits)
 
void process (const T &inreal, const T &inimag, qint32 &outreal, qint32 &outimag)
 
void process (qint32 &xreal, qint32 &ximag)
 
void setIQCorrection (bool iqCorrection)
 

Private Attributes

bool m_iqCorrection
 
float m_scalef
 
MovingAverageUtil< int32_t, int64_t, 1024 > m_iBeta
 
MovingAverageUtil< int32_t, int64_t, 1024 > m_qBeta
 
MovingAverageUtil< float, double, 128 > m_avgII
 
MovingAverageUtil< float, double, 128 > m_avgIQ
 
MovingAverageUtil< float, double, 128 > m_avgII2
 
MovingAverageUtil< float, double, 128 > m_avgQQ2
 
MovingAverageUtil< double, double, 128 > m_avgPhi
 
MovingAverageUtil< double, double, 128 > m_avgAmp
 

Detailed Description

template<typename T>
class AutoCorrector< T >

Definition at line 24 of file autocorrector.h.

Constructor & Destructor Documentation

◆ AutoCorrector()

template<typename T >
AutoCorrector< T >::AutoCorrector ( qint32  intBits)

Definition at line 45 of file autocorrector.h.

45  :
46  m_iqCorrection(false),
47  m_scalef((float) (1<<(intBits-1)))
48 {
49 }

Member Function Documentation

◆ process() [1/2]

template<typename T >
void AutoCorrector< T >::process ( const T &  inreal,
const T &  inimag,
qint32 &  outreal,
qint32 &  outimag 
)

Definition at line 52 of file autocorrector.h.

53 {
54  outreal = inreal;
55  outimag = inimag;
56  process(outreal, outimag);
57 }
void process(const T &inreal, const T &inimag, qint32 &outreal, qint32 &outimag)
Definition: autocorrector.h:52

◆ process() [2/2]

template<typename T >
void AutoCorrector< T >::process ( qint32 &  xreal,
qint32 &  ximag 
)

Definition at line 60 of file autocorrector.h.

References MovingAverageUtil< T, Total, N >::asDouble(), AutoCorrector< T >::m_avgAmp, AutoCorrector< T >::m_avgII, AutoCorrector< T >::m_avgII2, AutoCorrector< T >::m_avgIQ, AutoCorrector< T >::m_avgPhi, AutoCorrector< T >::m_avgQQ2, AutoCorrector< T >::m_iBeta, AutoCorrector< T >::m_iqCorrection, AutoCorrector< T >::m_qBeta, AutoCorrector< T >::m_scalef, and sqrt().

61 {
62  m_iBeta(xreal);
63  m_qBeta(ximag);
64 
65  if (m_iqCorrection)
66  {
67  // DC correction and conversion
68  float xi = (xreal - (int32_t) m_iBeta) / m_scalef;
69  float xq = (ximag - (int32_t) m_qBeta) / m_scalef;
70 
71  // phase imbalance
72  m_avgII(xi*xi); // <I", I">
73  m_avgIQ(xi*xq); // <I", Q">
74 
75 
76  if (m_avgII.asDouble() != 0) {
78  }
79 
80  float yi = xi - m_avgPhi.asDouble()*xq;
81  float yq = xq;
82 
83  // amplitude I/Q imbalance
84  m_avgII2(yi*yi); // <I, I>
85  m_avgQQ2(yq*yq); // <Q, Q>
86 
87  if (m_avgQQ2.asDouble() != 0) {
89  }
90 
91  // final correction
92  float zi = yi;
93  float zq = m_avgAmp.asDouble() * yq;
94 
95  // convert and store
96  xreal = zi * m_scalef;
97  ximag = zq * m_scalef;
98  }
99  else
100  {
101  xreal -= (int32_t) m_iBeta;
102  ximag -= (int32_t) m_qBeta;
103  }
104 }
MovingAverageUtil< float, double, 128 > m_avgQQ2
Definition: autocorrector.h:39
MovingAverageUtil< float, double, 128 > m_avgIQ
Definition: autocorrector.h:37
MovingAverageUtil< double, double, 128 > m_avgPhi
Definition: autocorrector.h:40
MovingAverageUtil< double, double, 128 > m_avgAmp
Definition: autocorrector.h:41
MovingAverageUtil< int32_t, int64_t, 1024 > m_iBeta
Definition: autocorrector.h:34
MovingAverageUtil< float, double, 128 > m_avgII
Definition: autocorrector.h:36
int int32_t
Definition: rtptypes_win.h:45
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2283
MovingAverageUtil< int32_t, int64_t, 1024 > m_qBeta
Definition: autocorrector.h:35
MovingAverageUtil< float, double, 128 > m_avgII2
Definition: autocorrector.h:38
double asDouble() const
Definition: movingaverage.h:57
+ Here is the call graph for this function:

◆ setIQCorrection()

template<typename T >
void AutoCorrector< T >::setIQCorrection ( bool  iqCorrection)
inline

Definition at line 30 of file autocorrector.h.

References AutoCorrector< T >::m_iqCorrection.

30 { m_iqCorrection = iqCorrection; }

Member Data Documentation

◆ m_avgAmp

template<typename T >
MovingAverageUtil<double, double, 128> AutoCorrector< T >::m_avgAmp
private

Definition at line 41 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().

◆ m_avgII

template<typename T >
MovingAverageUtil<float, double, 128> AutoCorrector< T >::m_avgII
private

Definition at line 36 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().

◆ m_avgII2

template<typename T >
MovingAverageUtil<float, double, 128> AutoCorrector< T >::m_avgII2
private

Definition at line 38 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().

◆ m_avgIQ

template<typename T >
MovingAverageUtil<float, double, 128> AutoCorrector< T >::m_avgIQ
private

Definition at line 37 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().

◆ m_avgPhi

template<typename T >
MovingAverageUtil<double, double, 128> AutoCorrector< T >::m_avgPhi
private

Definition at line 40 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().

◆ m_avgQQ2

template<typename T >
MovingAverageUtil<float, double, 128> AutoCorrector< T >::m_avgQQ2
private

Definition at line 39 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().

◆ m_iBeta

template<typename T >
MovingAverageUtil<int32_t, int64_t, 1024> AutoCorrector< T >::m_iBeta
private

Definition at line 34 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().

◆ m_iqCorrection

template<typename T >
bool AutoCorrector< T >::m_iqCorrection
private

◆ m_qBeta

template<typename T >
MovingAverageUtil<int32_t, int64_t, 1024> AutoCorrector< T >::m_qBeta
private

Definition at line 35 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().

◆ m_scalef

template<typename T >
float AutoCorrector< T >::m_scalef
private

Definition at line 33 of file autocorrector.h.

Referenced by AutoCorrector< T >::process().


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