GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
fir_filter.h
Go to the documentation of this file.
1 /*!
2  * \file fir_filter.h
3  * \brief Adapts a gnuradio gr_fir_filter designed with pm_remez
4  * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com
5  *
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
10  *
11  * GNSS-SDR is a software defined Global Navigation
12  * Satellite Systems receiver
13  *
14  * This file is part of GNSS-SDR.
15  *
16  * SPDX-License-Identifier: GPL-3.0-or-later
17  *
18  * -----------------------------------------------------------------------------
19  */
20 
21 #ifndef GNSS_SDR_FIR_FILTER_H
22 #define GNSS_SDR_FIR_FILTER_H
23 
26 #include "cshort_to_float_x2.h"
27 #include "gnss_block_interface.h"
28 #include "short_x2_to_cshort.h"
29 #include <gnuradio/blocks/file_sink.h>
30 #include <gnuradio/blocks/float_to_char.h>
31 #include <gnuradio/blocks/float_to_complex.h>
32 #include <gnuradio/blocks/float_to_short.h>
33 #include <gnuradio/gr_complex.h>
34 #ifdef GR_GREATER_38
35 #include <gnuradio/filter/fir_filter_blk.h>
36 #else
37 #include <gnuradio/filter/fir_filter_ccf.h>
38 #include <gnuradio/filter/fir_filter_fff.h>
39 #endif
40 #include <cmath>
41 #include <string>
42 #include <vector>
43 
45 
46 /*!
47  * \brief This class adapts a GNU Radio gr_fir_filter designed with pm_remez
48  *
49  * See Parks-McClellan FIR filter design, https://en.wikipedia.org/wiki/Parks-McClellan_filter_design_algorithm
50  * Calculates the optimal (in the Chebyshev/minimax sense) FIR filter impulse response
51  * given a set of band edges, the desired response on those bands, and the weight given
52  * to the error in those bands.
53  */
55 {
56 public:
57  //! Constructor
58  FirFilter(const ConfigurationInterface* configuration,
59  std::string role,
60  unsigned int in_streams,
61  unsigned int out_streams);
62 
63  //! Destructor
64  ~FirFilter() = default;
65 
66  inline std::string role() override
67  {
68  return role_;
69  }
70 
71  //! Returns "Fir_Filter"
72  inline std::string implementation() override
73  {
74  return "Fir_Filter";
75  }
76 
77  inline size_t item_size() override
78  {
79  return item_size_;
80  }
81 
82  void connect(gr::top_block_sptr top_block) override;
83  void disconnect(gr::top_block_sptr top_block) override;
84  gr::basic_block_sptr get_left_block() override;
85  gr::basic_block_sptr get_right_block() override;
86 
87 private:
88  void init();
89 
90  gr::filter::fir_filter_ccf::sptr fir_filter_ccf_;
91  gr::filter::fir_filter_fff::sptr fir_filter_fff_1_;
92  gr::filter::fir_filter_fff::sptr fir_filter_fff_2_;
93  gr::blocks::float_to_complex::sptr float_to_complex_;
94  gr::blocks::float_to_short::sptr float_to_short_1_;
95  gr::blocks::float_to_short::sptr float_to_short_2_;
96  short_x2_to_cshort_sptr short_x2_to_cshort_;
97  complex_byte_to_float_x2_sptr cbyte_to_float_x2_;
98  byte_x2_to_complex_byte_sptr char_x2_cbyte_;
99  cshort_to_float_x2_sptr cshort_to_float_x2_;
100  gr::blocks::float_to_char::sptr float_to_char_1_;
101  gr::blocks::float_to_char::sptr float_to_char_2_;
102  gr::blocks::file_sink::sptr file_sink_;
103  const ConfigurationInterface* config_;
104  std::vector<float> taps_;
105  std::string dump_filename_;
106  std::string input_item_type_;
107  std::string output_item_type_;
108  std::string taps_item_type_;
109  std::string role_;
110  size_t item_size_;
111  unsigned int in_streams_;
112  unsigned int out_streams_;
113  bool dump_;
114 };
115 
116 #endif
This class adapts a GNU Radio gr_fir_filter designed with pm_remez.
Definition: fir_filter.h:54
FirFilter(const ConfigurationInterface *configuration, std::string role, unsigned int in_streams, unsigned int out_streams)
Constructor.
This interface represents a GNSS block.
This abstract class represents an interface to configuration parameters.
~FirFilter()=default
Destructor.
std::string implementation() override
Returns "Fir_Filter".
Definition: fir_filter.h:72
This abstract class represents an interface to GNSS blocks.
Adapts two signed char streams into a std::complex<signed char> stream.
Adapts two short streams into a std::complex<short> stream.
Adapts a std::complex<short> stream into two float streams.
Adapts a std::complex<signed char> stream into two 16-bits (short) streams.