GNU Radio 3.4.2 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2010 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 /* 00024 * WARNING: This file is automatically generated by generate_gri_fir_XXX.py 00025 * Any changes made to this file will be overwritten. 00026 */ 00027 00028 00029 #ifndef INCLUDED_GRI_FIR_FILTER_WITH_BUFFER_SCC_H 00030 #define INCLUDED_GRI_FIR_FILTER_WITH_BUFFER_SCC_H 00031 00032 #include <vector> 00033 #include <gr_types.h> 00034 #include <gr_reverse.h> 00035 #include <string.h> 00036 #include <cstdio> 00037 00038 /*! 00039 * \brief FIR with internal buffer for short input, 00040 gr_complex output and gr_complex taps 00041 * \ingroup filter 00042 * 00043 */ 00044 00045 class gri_fir_filter_with_buffer_scc { 00046 00047 protected: 00048 std::vector<gr_complex> d_taps; // reversed taps 00049 short *d_buffer; 00050 unsigned int d_idx; 00051 00052 public: 00053 00054 // CONSTRUCTORS 00055 00056 /*! 00057 * \brief construct new FIR with given taps. 00058 * 00059 * Note that taps must be in forward order, e.g., coefficient 0 is 00060 * stored in new_taps[0], coefficient 1 is stored in 00061 * new_taps[1], etc. 00062 */ 00063 gri_fir_filter_with_buffer_scc (const std::vector<gr_complex> &taps); 00064 00065 ~gri_fir_filter_with_buffer_scc (); 00066 00067 // MANIPULATORS 00068 00069 /*! 00070 * \brief compute a single output value. 00071 * 00072 * \p input is a single input value of the filter type 00073 * 00074 * \returns the filtered input value. 00075 */ 00076 gr_complex filter (short input); 00077 00078 00079 /*! 00080 * \brief compute a single output value; designed for decimating filters. 00081 * 00082 * \p input is a single input value of the filter type. The value of dec is the 00083 * decimating value of the filter, so input[] must have dec valid values. 00084 * The filter pushes dec number of items onto the circ. buffer before computing 00085 * a single output. 00086 * 00087 * \returns the filtered input value. 00088 */ 00089 gr_complex filter (const short input[], unsigned long dec); 00090 00091 /*! 00092 * \brief compute an array of N output values. 00093 * 00094 * \p input must have (n - 1 + ntaps()) valid entries. 00095 * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values. 00096 */ 00097 void filterN (gr_complex output[], const short input[], 00098 unsigned long n); 00099 00100 /*! 00101 * \brief compute an array of N output values, decimating the input 00102 * 00103 * \p input must have (decimate * (n - 1) + ntaps()) valid entries. 00104 * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to 00105 * compute the output values. 00106 */ 00107 void filterNdec (gr_complex output[], const short input[], 00108 unsigned long n, unsigned long decimate); 00109 00110 /*! 00111 * \brief install \p new_taps as the current taps. 00112 */ 00113 void set_taps (const std::vector<gr_complex> &taps); 00114 00115 // ACCESSORS 00116 00117 /*! 00118 * \return number of taps in filter. 00119 */ 00120 unsigned ntaps () const { return d_taps.size (); } 00121 00122 /*! 00123 * \return current taps 00124 */ 00125 const std::vector<gr_complex> get_taps () const 00126 { 00127 return gr_reverse(d_taps); 00128 } 00129 }; 00130 00131 #endif /* INCLUDED_GRI_FIR_FILTER_WITH_BUFFER_SCC_H */