GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
notch_cc.h
Go to the documentation of this file.
1 /*!
2  * \file notch_cc.h
3  * \brief Implements a notch filter algorithm
4  * \author Antonio Ramos (antonio.ramosdet(at)gmail.com)
5  *
6  * -----------------------------------------------------------------------------
7  *
8  * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
9  *
10  * GNSS-SDR is a software defined Global Navigation
11  * Satellite Systems receiver
12  *
13  * This file is part of GNSS-SDR.
14  *
15  * SPDX-License-Identifier: GPL-3.0-or-later
16  *
17  * -----------------------------------------------------------------------------
18  */
19 
20 #ifndef GNSS_SDR_NOTCH_H
21 #define GNSS_SDR_NOTCH_H
22 
23 #if GNURADIO_USES_STD_POINTERS
24 #else
25 #include <boost/shared_ptr.hpp>
26 #endif
27 #include <gnuradio/block.h>
28 #include <gnuradio/fft/fft.h>
29 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
30 #include <cstdint>
31 #include <memory>
32 
33 class Notch;
34 
35 #if GNURADIO_USES_STD_POINTERS
36 using notch_sptr = std::shared_ptr<Notch>;
37 #else
38 using notch_sptr = boost::shared_ptr<Notch>;
39 #endif
40 
41 notch_sptr make_notch_filter(
42  float pfa,
43  float p_c_factor,
44  int32_t length_,
45  int32_t n_segments_est,
46  int32_t n_segments_reset);
47 
48 /*!
49  * \brief This class implements a real-time software-defined multi state notch filter
50  */
51 class Notch : public gr::block
52 {
53 public:
54  ~Notch() = default;
55 
56  void forecast(int noutput_items, gr_vector_int &ninput_items_required);
57 
58  int general_work(int noutput_items, gr_vector_int &ninput_items,
59  gr_vector_const_void_star &input_items,
60  gr_vector_void_star &output_items);
61 
62 private:
63  friend notch_sptr make_notch_filter(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
64  Notch(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
65  std::unique_ptr<gr::fft::fft_complex> d_fft;
66  volk_gnsssdr::vector<gr_complex> c_samples;
67  volk_gnsssdr::vector<float> angle_;
68  volk_gnsssdr::vector<float> power_spect;
69  gr_complex last_out;
70  gr_complex z_0;
71  gr_complex p_c_factor;
72  float pfa;
73  float noise_pow_est;
74  float thres_;
75  int32_t length_;
76  int32_t n_deg_fred;
77  uint32_t n_segments;
78  uint32_t n_segments_est;
79  uint32_t n_segments_reset;
80  bool filter_state_;
81 };
82 
83 #endif // GNSS_SDR_NOTCH_H
This class implements a real-time software-defined multi state notch filter.
Definition: notch_cc.h:51