GNU Radio 3.7.1 C++ API
fir_filter.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2004,2010,2012 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef INCLUDED_FILTER_FIR_FILTER_H
00024 #define INCLUDED_FILTER_FIR_FILTER_H
00025 
00026 #include <gnuradio/filter/api.h>
00027 #include <vector>
00028 #include <gnuradio/gr_complex.h>
00029 
00030 namespace gr {
00031   namespace filter {
00032     namespace kernel {
00033     
00034       class FILTER_API fir_filter_fff
00035       {
00036       public:
00037         fir_filter_fff(int decimation,
00038                        const std::vector<float> &taps);
00039         ~fir_filter_fff();
00040 
00041         void set_taps(const std::vector<float> &taps);
00042         void update_tap(float t, unsigned int index);
00043         std::vector<float> taps() const;
00044         unsigned int ntaps() const;
00045         
00046         float filter(const float input[]);
00047         void  filterN(float output[],
00048                       const float input[],
00049                       unsigned long n);
00050         void  filterNdec(float output[],
00051                          const float input[],
00052                          unsigned long n,
00053                          unsigned int decimate);
00054 
00055       protected:
00056         std::vector<float> d_taps;
00057         unsigned int  d_ntaps;
00058         float       **d_aligned_taps;
00059         float        *d_output;
00060         int           d_align;
00061         int           d_naligned;
00062       };
00063 
00064       /**************************************************************/
00065       
00066       class FILTER_API fir_filter_ccf
00067       {
00068       public:
00069         fir_filter_ccf(int decimation,
00070                        const std::vector<float> &taps);
00071         ~fir_filter_ccf();
00072 
00073         void set_taps(const std::vector<float> &taps);
00074         void update_tap(float t, unsigned int index);
00075         std::vector<float> taps() const;
00076         unsigned int ntaps() const;
00077 
00078         gr_complex filter(const gr_complex input[]);
00079         void filterN(gr_complex output[],
00080                      const gr_complex input[],
00081                      unsigned long n);
00082         void filterNdec(gr_complex output[],
00083                         const gr_complex input[],
00084                         unsigned long n,
00085                         unsigned int decimate);
00086 
00087       protected:
00088         std::vector<float> d_taps;
00089         unsigned int d_ntaps;
00090         float      **d_aligned_taps;
00091         gr_complex  *d_output;
00092         int          d_align;
00093         int          d_naligned;
00094       };
00095 
00096       /**************************************************************/
00097       
00098       class FILTER_API fir_filter_fcc
00099       {
00100       public:
00101         fir_filter_fcc(int decimation,
00102                        const std::vector<gr_complex> &taps);
00103         ~fir_filter_fcc();
00104 
00105         void set_taps(const std::vector<gr_complex> &taps);
00106         void update_tap(gr_complex t, unsigned int index);
00107         std::vector<gr_complex> taps() const;
00108         unsigned int ntaps() const;
00109 
00110         gr_complex filter(const float input[]);
00111         void filterN(gr_complex output[],
00112                      const float input[],
00113                      unsigned long n);
00114         void filterNdec(gr_complex output[],
00115                         const float input[],
00116                         unsigned long n,
00117                         unsigned int decimate);
00118 
00119       protected:
00120         std::vector<gr_complex> d_taps;
00121         unsigned int d_ntaps;
00122         gr_complex **d_aligned_taps;
00123         gr_complex  *d_output;
00124         int          d_align;
00125         int          d_naligned;
00126       };
00127 
00128       /**************************************************************/
00129       
00130       class FILTER_API fir_filter_ccc
00131       {
00132       public:
00133         fir_filter_ccc(int decimation,
00134                        const std::vector<gr_complex> &taps);
00135         ~fir_filter_ccc();
00136 
00137         void set_taps(const std::vector<gr_complex> &taps);
00138         void update_tap(gr_complex t, unsigned int index);
00139         std::vector<gr_complex> taps() const;
00140         unsigned int ntaps() const;
00141 
00142         gr_complex filter(const gr_complex input[]);
00143         void filterN(gr_complex output[],
00144                      const gr_complex input[],
00145                      unsigned long n);
00146         void filterNdec(gr_complex output[],
00147                         const gr_complex input[],
00148                         unsigned long n,
00149                         unsigned int decimate);
00150 
00151       protected:
00152         std::vector<gr_complex> d_taps;
00153         unsigned int d_ntaps;
00154         gr_complex **d_aligned_taps;
00155         gr_complex  *d_output;
00156         int          d_align;
00157         int          d_naligned;
00158       };
00159 
00160       /**************************************************************/
00161       
00162       class FILTER_API fir_filter_scc
00163       {
00164       public:
00165         fir_filter_scc(int decimation,
00166                        const std::vector<gr_complex> &taps);
00167         ~fir_filter_scc();
00168 
00169         void set_taps(const std::vector<gr_complex> &taps);
00170         void update_tap(gr_complex t, unsigned int index);
00171         std::vector<gr_complex> taps() const;
00172         unsigned int ntaps() const;
00173 
00174         gr_complex filter(const short input[]);
00175         void filterN(gr_complex output[],
00176                      const short input[],
00177                      unsigned long n);
00178         void filterNdec(gr_complex output[],
00179                         const short input[],
00180                         unsigned long n,
00181                         unsigned int decimate);
00182 
00183       protected:
00184         std::vector<gr_complex> d_taps;
00185         unsigned int d_ntaps;
00186         gr_complex **d_aligned_taps;
00187         gr_complex  *d_output;
00188         int          d_align;
00189         int          d_naligned;
00190       };
00191 
00192       /**************************************************************/
00193       
00194       class FILTER_API fir_filter_fsf
00195       {
00196       public:
00197         fir_filter_fsf(int decimation,
00198                        const std::vector<float> &taps);
00199         ~fir_filter_fsf();
00200 
00201         void set_taps(const std::vector<float> &taps);
00202         void update_tap(float t, unsigned int index);
00203         std::vector<float> taps() const;
00204         unsigned int ntaps() const;
00205 
00206         short filter(const float input[]);
00207         void filterN(short output[],
00208                      const float input[],
00209                      unsigned long n);
00210         void filterNdec(short output[],
00211                         const float input[],
00212                         unsigned long n,
00213                         unsigned int decimate);
00214 
00215       protected:
00216         std::vector<float> d_taps;
00217         unsigned int d_ntaps;
00218         float      **d_aligned_taps;
00219         short       *d_output;
00220         int          d_align;
00221         int          d_naligned;
00222       };
00223 
00224     } /* namespace kernel */
00225   } /* namespace filter */
00226 } /* namespace gr */
00227 
00228 #endif /* INCLUDED_FILTER_FIR_FILTER_H */