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 Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Projector Class Reference

#include <projector.h>

Public Types

enum  ProjectionType {
  ProjectionReal = 0, ProjectionImag, ProjectionMagLin, ProjectionMagSq,
  ProjectionMagDB, ProjectionPhase, ProjectionDPhase, ProjectionBPSK,
  ProjectionQPSK, Projection8PSK, Projection16PSK, nbProjectionTypes
}
 

Public Member Functions

 Projector (ProjectionType projectionType)
 
 ~Projector ()
 
ProjectionType getProjectionType () const
 
void settProjectionType (ProjectionType projectionType)
 
void setCache (Real *cache)
 
void setCacheMaster (bool cacheMaster)
 
Real run (const Sample &s)
 

Static Private Member Functions

static Real normalizeAngle (Real angle)
 

Private Attributes

ProjectionType m_projectionType
 
Real m_prevArg
 
Realm_cache
 
bool m_cacheMaster
 

Detailed Description

Definition at line 22 of file projector.h.

Member Enumeration Documentation

◆ ProjectionType

Enumerator
ProjectionReal 

Extract real part.

ProjectionImag 

Extract imaginary part.

ProjectionMagLin 

Calculate linear magnitude or modulus.

ProjectionMagSq 

Calculate linear squared magnitude or power.

ProjectionMagDB 

Calculate logarithmic (dB) of squared magnitude.

ProjectionPhase 

Calculate phase.

ProjectionDPhase 

Calculate phase derivative i.e. instantaneous frequency scaled to sample rate.

ProjectionBPSK 

Phase comparator BPSK evaluation.

ProjectionQPSK 

Phase comparator QPSK evaluation.

Projection8PSK 

Phase comparator 8-PSK evaluation.

Projection16PSK 

Phase comparator 16-PSK evaluation.

nbProjectionTypes 

Gives the number of projections in the enum.

Definition at line 25 of file projector.h.

26  {
27  ProjectionReal = 0,
39  };
Calculate logarithmic (dB) of squared magnitude.
Definition: projector.h:31
Phase comparator 8-PSK evaluation.
Definition: projector.h:36
Gives the number of projections in the enum.
Definition: projector.h:38
Phase comparator 16-PSK evaluation.
Definition: projector.h:37
Phase comparator BPSK evaluation.
Definition: projector.h:34
Calculate phase.
Definition: projector.h:32
Calculate linear magnitude or modulus.
Definition: projector.h:29
Calculate linear squared magnitude or power.
Definition: projector.h:30
Calculate phase derivative i.e. instantaneous frequency scaled to sample rate.
Definition: projector.h:33
Extract imaginary part.
Definition: projector.h:28
Phase comparator QPSK evaluation.
Definition: projector.h:35
Extract real part.
Definition: projector.h:27

Constructor & Destructor Documentation

◆ Projector()

Projector::Projector ( ProjectionType  projectionType)

Definition at line 23 of file projector.cpp.

23  :
24  m_projectionType(projectionType),
25  m_prevArg(0.0f),
26  m_cache(0),
27  m_cacheMaster(true)
28 {
29 }
ProjectionType m_projectionType
Definition: projector.h:53
Real * m_cache
Definition: projector.h:55
Real m_prevArg
Definition: projector.h:54
bool m_cacheMaster
Definition: projector.h:56

◆ ~Projector()

Projector::~Projector ( )

Definition at line 31 of file projector.cpp.

32 {
33 }

Member Function Documentation

◆ getProjectionType()

ProjectionType Projector::getProjectionType ( ) const
inline

Definition at line 44 of file projector.h.

Referenced by ScopeVis::TriggerCondition::setData(), and ScopeVis::TriggerComparator::triggered().

44 { return m_projectionType; }
ProjectionType m_projectionType
Definition: projector.h:53
+ Here is the caller graph for this function:

◆ normalizeAngle()

Real Projector::normalizeAngle ( Real  angle)
staticprivate

Definition at line 204 of file projector.cpp.

References M_PI.

Referenced by run().

205 {
206  while (angle <= -M_PI) {
207  angle += 2.0*M_PI;
208  }
209  while (angle > M_PI) {
210  angle -= 2.0*M_PI;
211  }
212  return angle;
213 }
#define M_PI
Definition: rdsdemod.cpp:27
+ Here is the caller graph for this function:

◆ run()

Real Projector::run ( const Sample s)

Definition at line 35 of file projector.cpp.

References arg(), m_cache, m_cacheMaster, Sample::m_imag, M_PI, m_prevArg, m_projectionType, Sample::m_real, normalizeAngle(), Projection16PSK, Projection8PSK, ProjectionBPSK, ProjectionDPhase, ProjectionImag, ProjectionMagDB, ProjectionMagLin, ProjectionMagSq, ProjectionPhase, ProjectionQPSK, ProjectionReal, SDR_RX_SCALEF, and sqrt().

Referenced by ScopeVis::TriggerComparator::triggered().

36 {
37  Real v;
38 
39  if ((m_cache) && !m_cacheMaster) {
40  return m_cache[(int) m_projectionType];
41  }
42  else
43  {
44  switch (m_projectionType)
45  {
46  case ProjectionImag:
47  v = s.m_imag / SDR_RX_SCALEF;
48  break;
49  case ProjectionMagLin:
50  {
51  Real re = s.m_real / SDR_RX_SCALEF;
52  Real im = s.m_imag / SDR_RX_SCALEF;
53  Real magsq = re*re + im*im;
54  v = std::sqrt(magsq);
55  }
56  break;
57  case ProjectionMagSq:
58  {
59  Real re = s.m_real / SDR_RX_SCALEF;
60  Real im = s.m_imag / SDR_RX_SCALEF;
61  v = re*re + im*im;
62  }
63  break;
64  case ProjectionMagDB:
65  {
66  Real re = s.m_real / SDR_RX_SCALEF;
67  Real im = s.m_imag / SDR_RX_SCALEF;
68  Real magsq = re*re + im*im;
69  v = log10f(magsq) * 10.0f;
70  }
71  break;
72  case ProjectionPhase:
73  v = std::atan2((float) s.m_imag, (float) s.m_real) / M_PI;
74  break;
75  case ProjectionDPhase:
76  {
77  Real curArg = std::atan2((float) s.m_imag, (float) s.m_real);
78  Real dPhi = (curArg - m_prevArg) / M_PI;
79  m_prevArg = curArg;
80 
81  if (dPhi < -1.0f) {
82  dPhi += 2.0f;
83  } else if (dPhi > 1.0f) {
84  dPhi -= 2.0f;
85  }
86 
87  v = dPhi;
88  }
89  break;
90  case ProjectionBPSK:
91  {
92  Real arg = std::atan2((float) s.m_imag, (float) s.m_real);
93  v = normalizeAngle(2*arg) / (2.0*M_PI); // generic estimation around 0
94  // mapping on 2 symbols
95  if (arg < -M_PI/2) {
96  v -= 1.0/2;
97  } else if (arg < M_PI/2) {
98  v += 1.0/2;
99  } else if (arg < M_PI) {
100  v -= 1.0/2;
101  }
102  }
103  break;
104  case ProjectionQPSK:
105  {
106  Real arg = std::atan2((float) s.m_imag, (float) s.m_real);
107  v = normalizeAngle(4*arg) / (4.0*M_PI); // generic estimation around 0
108  // mapping on 4 symbols
109  if (arg < -3*M_PI/4) {
110  v -= 3.0/4;
111  } else if (arg < -M_PI/4) {
112  v -= 1.0/4;
113  } else if (arg < M_PI/4) {
114  v += 1.0/4;
115  } else if (arg < 3*M_PI/4) {
116  v += 3.0/4;
117  } else if (arg < M_PI) {
118  v -= 3.0/4;
119  }
120  }
121  break;
122  case Projection8PSK:
123  {
124  Real arg = std::atan2((float) s.m_imag, (float) s.m_real);
125  v = normalizeAngle(8*arg) / (8.0*M_PI); // generic estimation around 0
126  // mapping on 8 symbols
127  if (arg < -7*M_PI/8) {
128  v -= 7.0/8;
129  } else if (arg < -5*M_PI/8) {
130  v -= 5.0/8;
131  } else if (arg < -3*M_PI/8) {
132  v -= 3.0/8;
133  } else if (arg < -M_PI/8) {
134  v -= 1.0/8;
135  } else if (arg < M_PI/8) {
136  v += 1.0/8;
137  } else if (arg < 3*M_PI/8) {
138  v += 3.0/8;
139  } else if (arg < 5*M_PI/8) {
140  v += 5.0/8;
141  } else if (arg < 7*M_PI/8) {
142  v += 7.0/8;
143  } else if (arg < M_PI) {
144  v -= 7.0/8;
145  }
146  }
147  break;
148  case Projection16PSK:
149  {
150  Real arg = std::atan2((float) s.m_imag, (float) s.m_real);
151  v = normalizeAngle(16*arg) / (16.0*M_PI); // generic estimation around 0
152  // mapping on 16 symbols
153  if (arg < -15*M_PI/16) {
154  v -= 15.0/16;
155  } else if (arg < -13*M_PI/16) {
156  v -= 13.0/6;
157  } else if (arg < -11*M_PI/16) {
158  v -= 11.0/16;
159  } else if (arg < -9*M_PI/16) {
160  v -= 9.0/16;
161  } else if (arg < -7*M_PI/16) {
162  v -= 7.0/16;
163  } else if (arg < -5*M_PI/16) {
164  v -= 5.0/16;
165  } else if (arg < -3*M_PI/16) {
166  v -= 3.0/16;
167  } else if (arg < -M_PI/16) {
168  v -= 1.0/16;
169  } else if (arg < M_PI/16) {
170  v += 1.0/16;
171  } else if (arg < 3.0*M_PI/16) {
172  v += 3.0/16;
173  } else if (arg < 5.0*M_PI/16) {
174  v += 5.0/16;
175  } else if (arg < 7.0*M_PI/16) {
176  v += 7.0/16;
177  } else if (arg < 9.0*M_PI/16) {
178  v += 9.0/16;
179  } else if (arg < 11.0*M_PI/16) {
180  v += 11.0/16;
181  } else if (arg < 13.0*M_PI/16) {
182  v += 13.0/16;
183  } else if (arg < 15.0*M_PI/16) {
184  v += 15.0/16;
185  } else if (arg < M_PI) {
186  v -= 15.0/16;
187  }
188  }
189  break;
190  case ProjectionReal:
191  default:
192  v = s.m_real / SDR_RX_SCALEF;
193  break;
194  }
195 
196  if (m_cache) {
197  m_cache[(int) m_projectionType] = v;
198  }
199 
200  return v;
201  }
202 }
ProjectionType m_projectionType
Definition: projector.h:53
Calculate logarithmic (dB) of squared magnitude.
Definition: projector.h:31
Phase comparator 8-PSK evaluation.
Definition: projector.h:36
#define M_PI
Definition: rdsdemod.cpp:27
Phase comparator 16-PSK evaluation.
Definition: projector.h:37
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
#define SDR_RX_SCALEF
Definition: dsptypes.h:33
Phase comparator BPSK evaluation.
Definition: projector.h:34
Calculate phase.
Definition: projector.h:32
FixReal m_real
Definition: dsptypes.h:64
Real * m_cache
Definition: projector.h:55
Calculate linear magnitude or modulus.
Definition: projector.h:29
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2283
Calculate linear squared magnitude or power.
Definition: projector.h:30
Real m_prevArg
Definition: projector.h:54
Calculate phase derivative i.e. instantaneous frequency scaled to sample rate.
Definition: projector.h:33
bool m_cacheMaster
Definition: projector.h:56
Extract imaginary part.
Definition: projector.h:28
FixReal m_imag
Definition: dsptypes.h:65
static Real normalizeAngle(Real angle)
Definition: projector.cpp:204
float Real
Definition: dsptypes.h:42
Phase comparator QPSK evaluation.
Definition: projector.h:35
Extract real part.
Definition: projector.h:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCache()

void Projector::setCache ( Real cache)
inline

Definition at line 46 of file projector.h.

46 { m_cache = cache; }
Real * m_cache
Definition: projector.h:55

◆ setCacheMaster()

void Projector::setCacheMaster ( bool  cacheMaster)
inline

Definition at line 47 of file projector.h.

47 { m_cacheMaster = cacheMaster; }
bool m_cacheMaster
Definition: projector.h:56

◆ settProjectionType()

void Projector::settProjectionType ( ProjectionType  projectionType)
inline

Definition at line 45 of file projector.h.

Referenced by ScopeVis::TriggerCondition::initProjector(), ScopeVis::TraceControl::initProjector(), and ScopeVis::TriggerCondition::setData().

45 { m_projectionType = projectionType; }
ProjectionType m_projectionType
Definition: projector.h:53
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_cache

Real* Projector::m_cache
private

Definition at line 55 of file projector.h.

Referenced by run().

◆ m_cacheMaster

bool Projector::m_cacheMaster
private

Definition at line 56 of file projector.h.

Referenced by run().

◆ m_prevArg

Real Projector::m_prevArg
private

Definition at line 54 of file projector.h.

Referenced by run().

◆ m_projectionType

ProjectionType Projector::m_projectionType
private

Definition at line 53 of file projector.h.

Referenced by run().


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