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