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.
ncof.h
Go to the documentation of this file.
1 // Copyright (C) 2016 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef INCLUDE_NCOF_H
19 #define INCLUDE_NCOF_H
20 
21 #include "dsp/dsptypes.h"
22 #include "export.h"
23 
25 private:
26  enum {
27  TableSize = (1 << 12),
28  };
29  static Real m_table[TableSize+1];
30  static bool m_tableInitialized;
31  static float m_tableSizeLimit;
32 
33  static void initTable();
34 
37 
38 public:
39  NCOF();
40 
41  void setFreq(Real freq, Real sampleRate);
42  void setPhase(Real phase) { m_phase = phase; }
43 
44  int nextPhase()
45  {
46  m_phase += m_phaseIncrement;
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  }
55 
56  Real next();
57  Complex nextIQ();
58  Complex nextIQ(float imbalance);
59  Complex nextQI();
60  Real get();
61  Complex getIQ();
62  void getIQ(Complex& c);
63  Complex getQI();
64  void getQI(Complex& c);
65 };
66 
67 #endif // INCLUDE_NCO_H
Real m_phaseIncrement
Definition: ncof.h:35
Definition: ncof.h:24
static float m_tableSizeLimit
Definition: ncof.h:31
void setPhase(Real phase)
Definition: ncof.h:42
int nextPhase()
Definition: ncof.h:44
static bool m_tableInitialized
Definition: ncof.h:30
Real m_phase
Definition: ncof.h:36
#define SDRBASE_API
Definition: export.h:40
std::complex< Real > Complex
Definition: dsptypes.h:43
float Real
Definition: dsptypes.h:42