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.
afsquelch.h
Go to the documentation of this file.
1 // Copyright (C) 2015 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_GPL_DSP_AFSQUELCH_H_
19 #define INCLUDE_GPL_DSP_AFSQUELCH_H_
20 
21 #include "dsp/dsptypes.h"
22 #include "dsp/movingaverage.h"
23 #include "export.h"
24 
29 public:
30  // constructor with default values
31  AFSquelch();
32  virtual ~AFSquelch();
33 
34  // setup the basic parameters and coefficients
35  void setCoefficients(
36  unsigned int N,
37  unsigned int nbAvg,
38  unsigned int sampleRate,
39  unsigned int samplesAttack,
40  unsigned int samplesDecay,
41  const double *tones);
42 
43  // set the detection threshold
44  void setThreshold(double _threshold);
45 
46  // analyze a sample set and optionally filter
47  // the tone frequencies.
48  bool analyze(double sample); // input signal sample
49  bool evaluate(); // evaluate result
50 
51  // get the tone set
52  const double *getToneSet() const
53  {
54  return m_toneSet;
55  }
56 
57  bool open() const {
58  return m_isOpen;
59  }
60 
61  void reset(); // reset the analysis algorithm
62 
63 protected:
64  void feedback(double sample);
65  void feedForward();
66 
67 private:
68  unsigned int m_nbAvg;
69  unsigned int m_N;
70  unsigned int m_sampleRate;
71  unsigned int m_samplesProcessed;
72  unsigned int m_samplesAvgProcessed;
73  unsigned int m_maxPowerIndex;
74  unsigned int m_nTones;
75  unsigned int m_samplesAttack;
76  unsigned int m_attackCount;
77  unsigned int m_samplesDecay;
78  unsigned int m_decayCount;
79  unsigned int m_squelchCount;
80  bool m_isOpen;
81  double m_threshold;
82  double *m_k;
83  double *m_coef;
84  double *m_toneSet;
85  double *m_u0;
86  double *m_u1;
87  double *m_power;
88  std::vector<MovingAverage<double> > m_movingAverages;
89 };
90 
91 
92 #endif /* INCLUDE_GPL_DSP_CTCSSDETECTOR_H_ */
double * m_k
Definition: afsquelch.h:82
unsigned int m_samplesAvgProcessed
Definition: afsquelch.h:72
const double * getToneSet() const
Definition: afsquelch.h:52
double * m_u0
Definition: afsquelch.h:85
double * m_coef
Definition: afsquelch.h:83
double * m_u1
Definition: afsquelch.h:86
double * m_power
Definition: afsquelch.h:87
unsigned int m_N
Definition: afsquelch.h:69
unsigned int m_maxPowerIndex
Definition: afsquelch.h:73
unsigned int m_squelchCount
Definition: afsquelch.h:79
double m_threshold
Definition: afsquelch.h:81
std::vector< MovingAverage< double > > m_movingAverages
Definition: afsquelch.h:88
bool m_isOpen
Definition: afsquelch.h:80
unsigned int m_samplesProcessed
Definition: afsquelch.h:71
unsigned int m_samplesAttack
Definition: afsquelch.h:75
unsigned int m_samplesDecay
Definition: afsquelch.h:77
unsigned int m_nbAvg
number of power samples taken for moving average
Definition: afsquelch.h:68
unsigned int m_attackCount
Definition: afsquelch.h:76
unsigned int m_nTones
Definition: afsquelch.h:74
unsigned int m_decayCount
Definition: afsquelch.h:78
double * m_toneSet
Definition: afsquelch.h:84
#define SDRBASE_API
Definition: export.h:40
unsigned int m_sampleRate
Definition: afsquelch.h:70
bool open() const
Definition: afsquelch.h:57