Adding ability for FIR filter with internal buffer to decimate.
[debian/gnuradio] / gnuradio-core / src / lib / filter / gri_fir_filter_with_buffer_XXX.h.t
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2010 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio 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  * GNU Radio 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 GNU Radio; 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  * WARNING: This file is automatically generated by generate_gri_fir_XXX.py
25  * Any changes made to this file will be overwritten.
26  */
27
28
29 #ifndef @GUARD_NAME@
30 #define @GUARD_NAME@
31
32 #include <vector>
33 #include <gr_types.h>
34 #include <gr_reverse.h>
35 #include <string.h>
36 #include <cstdio>
37
38 /*!
39  * \brief FIR with internal buffer for @I_TYPE@ input, 
40           @O_TYPE@ output and @TAP_TYPE@ taps
41  * \ingroup filter
42  * 
43  */
44
45 class @NAME@ {
46
47 protected:
48   std::vector<@TAP_TYPE@>       d_taps;         // reversed taps
49   @I_TYPE@                     *d_buffer;
50   unsigned int                  d_idx;
51
52 public:
53
54   // CONSTRUCTORS
55
56   /*!
57    * \brief construct new FIR with given taps.
58    *
59    * Note that taps must be in forward order, e.g., coefficient 0 is
60    * stored in new_taps[0], coefficient 1 is stored in
61    * new_taps[1], etc.
62    */
63   @NAME@ (const std::vector<@TAP_TYPE@> &taps);
64
65   ~@NAME@ ();
66
67   // MANIPULATORS
68
69   /*!
70    * \brief compute a single output value.
71    *
72    * \p input is a single input value of the filter type
73    *
74    * \returns the filtered input value.
75    */
76   @O_TYPE@ filter (@I_TYPE@ input);
77
78   
79   /*!
80    * \brief compute a single output value; designed for decimating filters.
81    *
82    * \p input is a single input value of the filter type. The value of dec is the
83    *    decimating value of the filter, so input[] must have dec valid values.
84    *    The filter pushes dec number of items onto the circ. buffer before computing
85    *    a single output.
86    *
87    * \returns the filtered input value.
88    */
89   @O_TYPE@ filter (const @I_TYPE@ input[], unsigned long dec);
90
91   /*!
92    * \brief compute an array of N output values.
93    *
94    * \p input must have (n - 1 + ntaps()) valid entries.
95    * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values.
96    */
97   void filterN (@O_TYPE@ output[], const @I_TYPE@ input[],
98                 unsigned long n);
99
100   /*!
101    * \brief compute an array of N output values, decimating the input
102    *
103    * \p input must have (decimate * (n - 1) + ntaps()) valid entries.
104    * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to 
105    * compute the output values.
106    */
107   void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[],
108                    unsigned long n, unsigned long decimate);
109
110   /*!
111    * \brief install \p new_taps as the current taps.
112    */
113   void set_taps (const std::vector<@TAP_TYPE@> &taps);
114
115   // ACCESSORS
116
117   /*!
118    * \return number of taps in filter.
119    */
120   unsigned ntaps () const { return d_taps.size (); }
121
122   /*!
123    * \return current taps
124    */
125   const std::vector<@TAP_TYPE@> get_taps () const
126   {
127     return gr_reverse(d_taps);
128   }
129 };
130
131 #endif /* @GUARD_NAME@ */