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

#include <ncof.h>

Public Member Functions

 NCOF ()
 
void setFreq (Real freq, Real sampleRate)
 
void setPhase (Real phase)
 
int nextPhase ()
 
Real next ()
 Return next real sample. More...
 
Complex nextIQ ()
 Return next complex sample. More...
 
Complex nextIQ (float imbalance)
 Return next complex sample with an imbalance factor on I. More...
 
Complex nextQI ()
 Return next complex sample (reversed) More...
 
Real get ()
 Return current real sample (no phase increment) More...
 
Complex getIQ ()
 Return current complex sample (no phase increment) More...
 
void getIQ (Complex &c)
 Sets to the current complex sample (no phase increment) More...
 
Complex getQI ()
 Return current complex sample (no phase increment, reversed) More...
 
void getQI (Complex &c)
 Sets to the current complex sample (no phase increment, reversed) More...
 

Private Types

enum  { TableSize = (1 << 12) }
 

Static Private Member Functions

static void initTable ()
 

Private Attributes

Real m_phaseIncrement
 
Real m_phase
 

Static Private Attributes

static Real m_table [TableSize+1]
 
static bool m_tableInitialized = false
 
static float m_tableSizeLimit = (float) NCOF::TableSize
 

Detailed Description

Definition at line 24 of file ncof.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
TableSize 

Definition at line 26 of file ncof.h.

26  {
27  TableSize = (1 << 12),
28  };

Constructor & Destructor Documentation

◆ NCOF()

NCOF::NCOF ( )

Definition at line 44 of file ncof.cpp.

References initTable(), m_phase, and m_phaseIncrement.

45 {
46  initTable();
47  m_phase = 0.0f;
48  m_phaseIncrement = 0.0f;
49 }
Real m_phaseIncrement
Definition: ncof.h:35
static void initTable()
Definition: ncof.cpp:31
Real m_phase
Definition: ncof.h:36
+ Here is the call graph for this function:

Member Function Documentation

◆ get()

float NCOF::get ( )

Return current real sample (no phase increment)

Definition at line 83 of file ncof.cpp.

References m_phase, and m_table.

84 {
85  return m_table[(int) m_phase];
86 }
Real m_phase
Definition: ncof.h:36
static Real m_table[TableSize+1]
Definition: ncof.h:29

◆ getIQ() [1/2]

Complex NCOF::getIQ ( )

Return current complex sample (no phase increment)

Definition at line 88 of file ncof.cpp.

References m_phase, m_table, and TableSize.

89 {
90  return Complex(m_table[(int) m_phase], -m_table[((int) m_phase + TableSize / 4) % TableSize]);
91 }
Real m_phase
Definition: ncof.h:36
static Real m_table[TableSize+1]
Definition: ncof.h:29
std::complex< Real > Complex
Definition: dsptypes.h:43

◆ getIQ() [2/2]

void NCOF::getIQ ( Complex c)

Sets to the current complex sample (no phase increment)

Definition at line 93 of file ncof.cpp.

References m_phase, m_table, and TableSize.

94 {
95  c.real(m_table[(int) m_phase]);
96  c.imag(-m_table[((int) m_phase + TableSize / 4) % TableSize]);
97 }
Real m_phase
Definition: ncof.h:36
static Real m_table[TableSize+1]
Definition: ncof.h:29

◆ getQI() [1/2]

Complex NCOF::getQI ( )

Return current complex sample (no phase increment, reversed)

Definition at line 99 of file ncof.cpp.

References m_phase, m_table, and TableSize.

100 {
101  return Complex(-m_table[((int) m_phase + TableSize / 4) % TableSize], m_table[(int) m_phase]);
102 }
Real m_phase
Definition: ncof.h:36
static Real m_table[TableSize+1]
Definition: ncof.h:29
std::complex< Real > Complex
Definition: dsptypes.h:43

◆ getQI() [2/2]

void NCOF::getQI ( Complex c)

Sets to the current complex sample (no phase increment, reversed)

Definition at line 104 of file ncof.cpp.

References m_phase, m_table, and TableSize.

105 {
106  c.imag(m_table[(int) m_phase]);
107  c.real(-m_table[((int) m_phase + TableSize / 4) % TableSize]);
108 }
Real m_phase
Definition: ncof.h:36
static Real m_table[TableSize+1]
Definition: ncof.h:29

◆ initTable()

void NCOF::initTable ( )
staticprivate

Definition at line 31 of file ncof.cpp.

References cos(), i, M_PI, m_table, m_tableInitialized, and TableSize.

Referenced by NCOF().

32 {
33  if(m_tableInitialized) {
34  return;
35  }
36 
37  for(int i = 0; i <= TableSize; i++) {
38  m_table[i] = cos((2.0 * M_PI * i) / TableSize);
39  }
40 
41  m_tableInitialized = true;
42 }
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
int32_t i
Definition: decimators.h:244
#define M_PI
Definition: ncof.cpp:25
static bool m_tableInitialized
Definition: ncof.h:30
static Real m_table[TableSize+1]
Definition: ncof.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ next()

float NCOF::next ( )

Return next real sample.

Definition at line 57 of file ncof.cpp.

References m_table, and nextPhase().

Referenced by NFMMod::modulateSample(), TestMIThread::pullAF(), TestSourceThread::pullAF(), WFMMod::pullAF(), AMMod::pullAF(), NFMMod::pullAF(), FreeDVMod::pullAF(), and SSBMod::pullAF().

58 {
59  int phase = nextPhase();
60  return m_table[phase];
61 }
int nextPhase()
Definition: ncof.h:44
static Real m_table[TableSize+1]
Definition: ncof.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextIQ() [1/2]

Complex NCOF::nextIQ ( )

Return next complex sample.

Definition at line 63 of file ncof.cpp.

References m_table, nextPhase(), and TableSize.

Referenced by SSBDemod::feed(), FreqTracker::feed(), FreeDVDemod::feed(), ChannelAnalyzer::feed(), TestMIThread::generate(), TestSourceThread::generate(), SSBMod::pull(), FreeDVMod::pull(), and SSBMod::pullAF().

64 {
65  int phase = nextPhase();
66  return Complex(m_table[phase], -m_table[(phase + TableSize / 4) % TableSize]);
67 }
int nextPhase()
Definition: ncof.h:44
static Real m_table[TableSize+1]
Definition: ncof.h:29
std::complex< Real > Complex
Definition: dsptypes.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextIQ() [2/2]

Complex NCOF::nextIQ ( float  imbalance)

Return next complex sample with an imbalance factor on I.

Definition at line 69 of file ncof.cpp.

References m_table, nextPhase(), and TableSize.

70 {
71  int phase = nextPhase();
72  int phaseQ = imbalance < 0.0 ? phase + (int) (imbalance*TableSize) : phase;
73  int phaseI = imbalance < 0.0 ? phase : phase + (int) (imbalance*TableSize);
74  return Complex(m_table[phaseI % TableSize], -m_table[(phaseQ + TableSize / 4) % TableSize]);
75 }
int nextPhase()
Definition: ncof.h:44
static Real m_table[TableSize+1]
Definition: ncof.h:29
std::complex< Real > Complex
Definition: dsptypes.h:43
+ Here is the call graph for this function:

◆ nextPhase()

int NCOF::nextPhase ( )
inline

Definition at line 44 of file ncof.h.

Referenced by next(), nextIQ(), and nextQI().

45  {
47  while(m_phase >= m_tableSizeLimit) {
48  m_phase -= TableSize;
49  }
50  while(m_phase < 0.0) {
51  m_phase += TableSize;
52  }
53  return (int) m_phase;
54  }
Real m_phaseIncrement
Definition: ncof.h:35
static float m_tableSizeLimit
Definition: ncof.h:31
Real m_phase
Definition: ncof.h:36
+ Here is the caller graph for this function:

◆ nextQI()

Complex NCOF::nextQI ( )

Return next complex sample (reversed)

Definition at line 77 of file ncof.cpp.

References m_table, nextPhase(), and TableSize.

Referenced by SSBMod::pullAF().

78 {
79  int phase = nextPhase();
80  return Complex(-m_table[(phase + TableSize / 4) % TableSize], m_table[phase]);
81 }
int nextPhase()
Definition: ncof.h:44
static Real m_table[TableSize+1]
Definition: ncof.h:29
std::complex< Real > Complex
Definition: dsptypes.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFreq()

void NCOF::setFreq ( Real  freq,
Real  sampleRate 
)

◆ setPhase()

void NCOF::setPhase ( Real  phase)
inline

Definition at line 42 of file ncof.h.

Referenced by WFMMod::pullAF(), AMMod::pullAF(), NFMMod::pullAF(), FreeDVMod::pullAF(), and SSBMod::pullAF().

42 { m_phase = phase; }
Real m_phase
Definition: ncof.h:36
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_phase

Real NCOF::m_phase
private

Definition at line 36 of file ncof.h.

Referenced by get(), getIQ(), getQI(), and NCOF().

◆ m_phaseIncrement

Real NCOF::m_phaseIncrement
private

Definition at line 35 of file ncof.h.

Referenced by NCOF(), and setFreq().

◆ m_table

Real NCOF::m_table
staticprivate

Definition at line 29 of file ncof.h.

Referenced by get(), getIQ(), getQI(), initTable(), next(), nextIQ(), and nextQI().

◆ m_tableInitialized

bool NCOF::m_tableInitialized = false
staticprivate

Definition at line 30 of file ncof.h.

Referenced by initTable().

◆ m_tableSizeLimit

float NCOF::m_tableSizeLimit = (float) NCOF::TableSize
staticprivate

Definition at line 31 of file ncof.h.


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