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.
ctcssdetector.h
Go to the documentation of this file.
1 /*
2  * ctcssdetector.h
3  *
4  * Created on: Jun 16, 2015
5  * Author: f4exb
6  * See: http://www.embedded.com/design/connectivity/4025660/Detecting-CTCSS-tones-with-Goertzel-s-algorithm
7  */
8 
9 #ifndef INCLUDE_GPL_DSP_CTCSSDETECTOR_H_
10 #define INCLUDE_GPL_DSP_CTCSSDETECTOR_H_
11 
12 #include "dsp/dsptypes.h"
13 #include "export.h"
14 
20 public:
21  // Constructors and Destructor
22  CTCSSDetector();
23  // allows user defined CTCSS tone set
24  CTCSSDetector(int _nTones, Real *tones);
25  virtual ~CTCSSDetector();
26 
27  // setup the basic parameters and coefficients
28  void setCoefficients(
29  int zN, // the algorithm "block" size
30  int SampleRate); // input signal sample rate
31 
32  // set the detection threshold
33  void setThreshold(double thold);
34 
35  // analyze a sample set and optionally filter
36  // the tone frequencies.
37  bool analyze(Real *sample); // input signal sample
38 
39  // get the number of defined tones.
40  int getNTones() const {
41  return nTones;
42  }
43 
44  // get the tone set
45  const Real *getToneSet() const
46  {
47  return toneSet;
48  }
49 
50  // get the currently detected tone, if any
51  bool getDetectedTone(int &maxTone) const
52  {
53  maxTone = maxPowerIndex;
54  return toneDetected;
55  }
56 
57  // Get the max power at the detected tone.
58  Real getMaxPower() const
59  {
60  return maxPower;
61  }
62 
63  void reset(); // reset the analysis algorithm
64 
65 protected:
66  // Override these to change behavior of the detector
67  virtual void initializePower();
68  virtual void evaluatePower();
69  void feedback(Real sample);
70  void feedForward();
71 
72 private:
73  int N;
75  int nTones;
80  Real *k;
83  Real *u0;
84  Real *u1;
86 };
87 
88 
89 #endif /* INCLUDE_GPL_DSP_CTCSSDETECTOR_H_ */
const Real * getToneSet() const
Definition: ctcssdetector.h:45
bool getDetectedTone(int &maxTone) const
Definition: ctcssdetector.h:51
int getNTones() const
Definition: ctcssdetector.h:40
Real getMaxPower() const
Definition: ctcssdetector.h:58
#define SDRBASE_API
Definition: export.h:40
float Real
Definition: dsptypes.h:42