The Inspector (GNU Radio module gr-inspector)
signal_detector_cvf.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2019 Free Software Foundation Inc..
4  *
5  * This 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; either version 3, or (at your option)
8  * any later version.
9  *
10  * This software 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 for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this software; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef INCLUDED_INSPECTOR_SIGNAL_DETECTOR_CVF_H
22 #define INCLUDED_INSPECTOR_SIGNAL_DETECTOR_CVF_H
23 
24 #include <gnuradio/sync_decimator.h>
25 #include <inspector/api.h>
26 
27 namespace gr {
28 namespace inspector {
29 
30 /*!
31  * \brief Signal detection block using energy detection.
32  * \ingroup inspector
33  *
34  * \details
35  * Takes input spectrum as complex float and performs an energy detection
36  * to find potential continuous signals and build a RF map (tuple
37  * of center frequency and bandwidth). The RF map gets passed as a
38  * message with center frequency and bandwidth information for each detected
39  * signal.
40  *
41  * Threshold for energy detection can either be set in dB or an automatic
42  * threshold calculation can be performed by setting a sensitivity between 0
43  * and 1. The PSD is then sorted and searched for relative power jumps with height
44  * (1-sensitivity) and the threshold is set to the sample before that jump
45  * (which should be the strongest noise sample).
46  *
47  * To surpress false detection in noisy scenarios, the minimum signal bandwidth
48  * can be set. All detected signals smaller than this value will not be written
49  * in the RF map.
50  *
51  * To average the PSD (and provide a better detection) an single pole IIR
52  * filter is implemented in this block. The parameter alpha can be set as
53  * block parameter. The IIR equation yields y[n] = alpha*x[n]+(1-alpha)*y[n-1].
54  *
55  * The bandwidth of the detected signals can be quantized relative to the
56  * sampling rate. This leads to less recalculations in the Signal Separator
57  * block. There, a filter must be recalculated, when the bandwidth of a signal
58  * changed.
59  */
60 class INSPECTOR_API signal_detector_cvf : virtual public gr::sync_decimator
61 {
62 public:
63  typedef boost::shared_ptr<signal_detector_cvf> sptr;
64 
65  /*!
66  * \brief Return a signal detector block instance.
67  *
68  * \param samp_rate Sample rate of the input signal
69  * \param fft_len Desired number of FFT points for the PSD. Also sets the input items
70  * consumed in evry work cycle. \param window_type Firdes window type to scale the
71  * input samples with \param threshold Threshold in dB for energy detection when
72  * automatic signal detection is disabled \param sensitivity Sensitivity value between
73  * 0 and 1 if automatic signal detection is enabled \param auto_threshold Bool to set
74  * automatic threshold calculation \param average Averaging factor in (0,1] (equal to
75  * alpha in IIR equation) \param quantization Bandwidth quantization yields
76  * quantization*samp_rate [Hz] \param min_bw Minimum signal bandwidth. Don't pass any
77  * narrower signals. \param filename Path to a file where the detections are logged.
78  * Leave empty for no log.
79  */
80  static sptr make(double samp_rate,
81  int fft_len = 1024,
82  int window_type = 0,
83  float threshold = 0.7,
84  float sensitivity = 0.2,
85  bool auto_threshold = true,
86  float average = 0.8,
87  float quantization = 0.01,
88  float min_bw = 0.0,
89  const char* filename = "");
90 
91  virtual void set_samp_rate(double d_samp_rate) = 0;
92  virtual void set_fft_len(int fft_len) = 0;
93 
94  /*!
95  * Takes integers and does internal cast to firdes::win_type
96  */
97  virtual void set_window_type(int d_window) = 0;
98 
99  virtual void set_threshold(float d_threshold) = 0;
100  virtual void set_sensitivity(float d_sensitivity) = 0;
101  virtual void set_auto_threshold(bool d_auto_threshold) = 0;
102  virtual void set_average(float d_average) = 0;
103 };
104 
105 } // namespace inspector
106 } // namespace gr
107 
108 #endif /* INCLUDED_INSPECTOR_SIGNAL_DETECTOR_CVF_H */
#define INSPECTOR_API
Definition: api.h:31
boost::shared_ptr< signal_detector_cvf > sptr
Definition: signal_detector_cvf.h:63
Definition: inspector_form.h:40
Signal detection block using energy detection.
Definition: signal_detector_cvf.h:60