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