diff options
Diffstat (limited to 'gnuradio-core/src/lib')
17 files changed, 1 insertions, 1222 deletions
diff --git a/gnuradio-core/src/lib/filter/Makefile.am b/gnuradio-core/src/lib/filter/Makefile.am index 93834d742..709ad603e 100644 --- a/gnuradio-core/src/lib/filter/Makefile.am +++ b/gnuradio-core/src/lib/filter/Makefile.am @@ -176,10 +176,6 @@ libfilter_la_common_SOURCES = \ gr_iir_filter_ffd.cc \ gr_sincos.c \ gr_single_pole_iir_filter_ff.cc \ - gr_single_pole_avg_filter_ff.cc \ - gr_single_pole_rec_filter_ff.cc \ - gr_single_zero_avg_filter_ff.cc \ - gr_single_zero_rec_filter_ff.cc \ gr_single_pole_iir_filter_cc.cc \ gri_goertzel.cc \ gri_mmse_fir_interpolator.cc \ @@ -238,17 +234,9 @@ grinclude_HEADERS = \ gr_iir_filter_ffd.h \ gr_rotator.h \ gr_sincos.h \ - gr_single_pole_avg.h \ - gr_single_pole_rec.h \ gr_single_pole_iir.h \ gr_single_pole_iir_filter_ff.h \ - gr_single_pole_avg_filter_ff.h \ - gr_single_pole_rec_filter_ff.h \ - gr_single_zero_avg_filter_ff.h \ - gr_single_zero_rec_filter_ff.h \ - gr_single_pole_iir_filter_cc.h \ - gr_single_zero_avg.h \ - gr_single_zero_rec.h \ + gr_single_pole_iir_filter_cc.h \ gri_goertzel.h \ gri_iir.h \ gri_mmse_fir_interpolator.h \ @@ -301,10 +289,6 @@ swiginclude_HEADERS = \ gr_hilbert_fc.i \ gr_iir_filter_ffd.i \ gr_single_pole_iir_filter_ff.i \ - gr_single_pole_avg_filter_ff.i \ - gr_single_pole_rec_filter_ff.i \ - gr_single_zero_avg_filter_ff.i \ - gr_single_zero_rec_filter_ff.i \ gr_single_pole_iir_filter_cc.i \ $(GENERATED_I) diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_avg.h b/gnuradio-core/src/lib/filter/gr_single_pole_avg.h deleted file mode 100644 index 91324fc50..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_avg.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_SINGLE_POLE_AVG_H_ -#define _GR_SINGLE_POLE_AVG_H_ - -#include <stdexcept> - -/*! - * \brief class template for single pole moving average filter - * \ingroup filter - */ -template<class o_type, class i_type, class tap_type> -class gr_single_pole_avg { -public: - /*! - * \brief construct new single pole moving average filter with given alpha - * - * computes y(i) = alpha * x(i) - (1-alpha) * y(i-1) - */ - gr_single_pole_avg (tap_type alpha = 1.0) - { - d_prev_input = 0; - set_taps (alpha); - } - - /*! - * \brief compute a single output value. - * \returns the filtered input value. - */ - o_type filter (const i_type input); - - /*! - * \brief compute an array of N output values. - * \p input must have n valid entries. - */ - void filterN (o_type output[], const i_type input[], unsigned long n); - - /*! - * \brief install \p alpha as the current taps. - */ - void set_taps (tap_type alpha) - { - if (alpha < 0 || alpha > 1) - throw std::out_of_range ("Alpha must be in [0, 1]\n"); - - d_alpha = alpha; - d_one_minus_alpha = 1.0 - alpha; - } - - //! reset state to zero - void reset () - { - d_prev_input = 0; - } - - tap_type prev_input () { return d_prev_input; } - -protected: - tap_type d_alpha; - tap_type d_one_minus_alpha; - tap_type d_prev_input; -}; - - -// -// general case. We may want to specialize this -// -template<class o_type, class i_type, class tap_type> -o_type -gr_single_pole_avg<o_type, i_type, tap_type>::filter (const i_type input) -{ - tap_type output; - - output = d_alpha * input - d_one_minus_alpha * d_prev_input; - d_prev_input = input; - - return (o_type) output; -} - - -template<class o_type, class i_type, class tap_type> -void -gr_single_pole_avg<o_type, i_type, tap_type>::filterN (o_type output[], - const i_type input[], - unsigned long n) -{ - for (unsigned i = 0; i < n; i++) - output[i] = filter (input[i]); -} - - -#endif /* _GR_SINGLE_POLE_AVG_H_ */ diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.cc b/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.cc deleted file mode 100644 index ee1f3ade1..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_single_pole_avg_filter_ff.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_single_pole_avg_filter_ff_sptr -gr_make_single_pole_avg_filter_ff (double alpha, unsigned int vlen) -{ - return gr_single_pole_avg_filter_ff_sptr(new gr_single_pole_avg_filter_ff(alpha, vlen)); -} - -gr_single_pole_avg_filter_ff::gr_single_pole_avg_filter_ff ( - double alpha, unsigned int vlen) - : gr_sync_block ("single_pole_avg_filter_ff", - gr_make_io_signature (1, 1, sizeof (float) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen), d_rec(vlen) -{ - set_taps(alpha); -} - -gr_single_pole_avg_filter_ff::~gr_single_pole_avg_filter_ff () -{ - // nop -} - -void -gr_single_pole_avg_filter_ff::set_taps (double alpha) -{ - for (unsigned int i = 0; i < d_vlen; i++) - d_rec[i].set_taps(alpha); -} - -int -gr_single_pole_avg_filter_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - unsigned int vlen = d_vlen; - - if (d_vlen == 1){ - for (int i = 0; i < noutput_items; i++) - out[i] = d_rec[0].filter (in[i]); - } - else { - for (int i = 0; i < noutput_items; i++){ - for (unsigned int j = 0; j < vlen; j++){ - *out++ = d_rec[j].filter (*in++); - } - } - } - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.h b/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.h deleted file mode 100644 index dddc0d8a6..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SINGLE_POLE_REC_FILTER_FF_H -#define INCLUDED_GR_SINGLE_POLE_REC_FILTER_FF_H - -#include <gr_sync_block.h> -#include <gr_single_pole_avg.h> -#include <stdexcept> - -class gr_single_pole_avg_filter_ff; -typedef boost::shared_ptr<gr_single_pole_avg_filter_ff> gr_single_pole_avg_filter_ff_sptr; - -gr_single_pole_avg_filter_ff_sptr -gr_make_single_pole_avg_filter_ff (double alpha, unsigned int vlen=1); - -/*! - * \brief single pole moving average filter with float input, float output - * \ingroup filter - * - * The input and output satisfy a difference equation of the form - - \f[ - y[n] - (1-alpha) y[n-1] = alpha x[n] - \f] - - * with the corresponding rational system function - - \f[ - H(z) = \frac{alpha}{1 - (1-alpha) z^{-1}} - \f] - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback tap. - */ -class gr_single_pole_avg_filter_ff : public gr_sync_block -{ - private: - friend gr_single_pole_avg_filter_ff_sptr - gr_make_single_pole_avg_filter_ff (double alpha, unsigned int vlen); - - unsigned int d_vlen; - std::vector<gr_single_pole_avg<float,float,double> > d_rec; - - gr_single_pole_avg_filter_ff (double alpha, unsigned int vlen); - - public: - ~gr_single_pole_avg_filter_ff (); - - void set_taps (double alpha); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.i b/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.i deleted file mode 100644 index 6edec23dd..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_avg_filter_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,single_pole_avg_filter_ff); - -gr_single_pole_avg_filter_ff_sptr -gr_make_single_pole_avg_filter_ff (double alpha, unsigned int vlen=1); - -class gr_single_pole_avg_filter_ff : public gr_sync_block -{ - public: - ~gr_single_pole_avg_filter_ff (); - - void set_taps (double alpha); -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_rec.h b/gnuradio-core/src/lib/filter/gr_single_pole_rec.h deleted file mode 100644 index 622048616..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_rec.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_SINGLE_POLE_REC_H_ -#define _GR_SINGLE_POLE_REC_H_ - -#include <stdexcept> - -/*! - * \brief class template for single pole recursive filter - */ -template<class o_type, class i_type, class tap_type> -class gr_single_pole_rec { -public: - /*! - * \brief construct new single pole IIR with given alpha - * - * computes y(i) = alpha * x(i) - (1-alpha) * y(i-1) - */ - gr_single_pole_rec (tap_type alpha = 1.0) - { - d_prev_output = 0; - set_taps (alpha); - } - - /*! - * \brief compute a single output value. - * \returns the filtered input value. - */ - o_type filter (const i_type input); - - /*! - * \brief compute an array of N output values. - * \p input must have n valid entries. - */ - void filterN (o_type output[], const i_type input[], unsigned long n); - - /*! - * \brief install \p alpha as the current taps. - */ - void set_taps (tap_type alpha) - { - if (alpha < 0 || alpha > 1) - throw std::out_of_range ("Alpha must be in [0, 1]\n"); - - d_alpha = alpha; - d_one_minus_alpha = 1.0 - alpha; - } - - //! reset state to pole - void reset () - { - d_prev_output = 0; - } - - tap_type prev_output () { return d_prev_output; } - -protected: - tap_type d_alpha; - tap_type d_one_minus_alpha; - tap_type d_prev_output; -}; - - -// -// general case. We may want to specialize this -// -template<class o_type, class i_type, class tap_type> -o_type -gr_single_pole_rec<o_type, i_type, tap_type>::filter (const i_type input) -{ - tap_type output; - - output = d_alpha * input + d_one_minus_alpha * d_prev_output; - d_prev_output = output; - - return (o_type) output; -} - - -template<class o_type, class i_type, class tap_type> -void -gr_single_pole_rec<o_type, i_type, tap_type>::filterN (o_type output[], - const i_type input[], - unsigned long n) -{ - for (unsigned i = 0; i < n; i++) - output[i] = filter (input[i]); -} - - -#endif /* _GR_SINGLE_POLE_REC_H_ */ diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.cc b/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.cc deleted file mode 100644 index 683bafb28..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_single_pole_rec_filter_ff.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_single_pole_rec_filter_ff_sptr -gr_make_single_pole_rec_filter_ff (double alpha, unsigned int vlen) -{ - return gr_single_pole_rec_filter_ff_sptr(new gr_single_pole_rec_filter_ff(alpha, vlen)); -} - -gr_single_pole_rec_filter_ff::gr_single_pole_rec_filter_ff ( - double alpha, unsigned int vlen) - : gr_sync_block ("single_pole_rec_filter_ff", - gr_make_io_signature (1, 1, sizeof (float) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen), d_rec(vlen) -{ - set_taps(alpha); -} - -gr_single_pole_rec_filter_ff::~gr_single_pole_rec_filter_ff () -{ - // nop -} - -void -gr_single_pole_rec_filter_ff::set_taps (double alpha) -{ - for (unsigned int i = 0; i < d_vlen; i++) - d_rec[i].set_taps(alpha); -} - -int -gr_single_pole_rec_filter_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - unsigned int vlen = d_vlen; - - if (d_vlen == 1){ - for (int i = 0; i < noutput_items; i++) - out[i] = d_rec[0].filter (in[i]); - } - else { - for (int i = 0; i < noutput_items; i++){ - for (unsigned int j = 0; j < vlen; j++){ - *out++ = d_rec[j].filter (*in++); - } - } - } - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.h b/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.h deleted file mode 100644 index 66ef237c4..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SINGLE_POLE_REC_FILTER_FF_H -#define INCLUDED_GR_SINGLE_POLE_REC_FILTER_FF_H - -#include <gr_sync_block.h> -#include <gr_single_pole_rec.h> -#include <stdexcept> - -class gr_single_pole_rec_filter_ff; -typedef boost::shared_ptr<gr_single_pole_rec_filter_ff> gr_single_pole_rec_filter_ff_sptr; - -gr_single_pole_rec_filter_ff_sptr -gr_make_single_pole_rec_filter_ff (double alpha, unsigned int vlen=1); - -/*! - * \brief single pole recursive filter with float input, float output - * \ingroup filter - * - * The input and output satisfy a difference equation of the form - - \f[ - y[n] - (1-alpha) y[n-1] = alpha x[n] - \f] - - * with the corresponding rational system function - - \f[ - H(z) = \frac{alpha}{1 - (1-alpha) z^{-1}} - \f] - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback tap. - */ -class gr_single_pole_rec_filter_ff : public gr_sync_block -{ - private: - friend gr_single_pole_rec_filter_ff_sptr - gr_make_single_pole_rec_filter_ff (double alpha, unsigned int vlen); - - unsigned int d_vlen; - std::vector<gr_single_pole_rec<float,float,double> > d_rec; - - gr_single_pole_rec_filter_ff (double alpha, unsigned int vlen); - - public: - ~gr_single_pole_rec_filter_ff (); - - void set_taps (double alpha); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.i b/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.i deleted file mode 100644 index 90213b9d9..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_pole_rec_filter_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,single_pole_rec_filter_ff); - -gr_single_pole_rec_filter_ff_sptr -gr_make_single_pole_rec_filter_ff (double alpha, unsigned int vlen=1); - -class gr_single_pole_rec_filter_ff : public gr_sync_block -{ - public: - ~gr_single_pole_rec_filter_ff (); - - void set_taps (double alpha); -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_zero_avg.h b/gnuradio-core/src/lib/filter/gr_single_zero_avg.h deleted file mode 100644 index 2c49c1e23..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_zero_avg.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_SINGLE_ZERO_AVG_H_ -#define _GR_SINGLE_ZERO_AVG_H_ - -#include <stdexcept> - -/*! - * \brief class template for single zero moving average filter - */ -template<class o_type, class i_type, class tap_type> -class gr_single_zero_avg { -public: - /*! - * \brief construct new single zero moving average filter with given alpha - * - * computes y(i) = alpha * x(i) + (1-alpha) * y(i-1) - */ - gr_single_zero_avg (tap_type alpha = 1.0) - { - d_prev_input = 0; - set_taps (alpha); - } - - /*! - * \brief compute a single output value. - * \returns the filtered input value. - */ - o_type filter (const i_type input); - - /*! - * \brief compute an array of N output values. - * \p input must have n valid entries. - */ - void filterN (o_type output[], const i_type input[], unsigned long n); - - /*! - * \brief install \p alpha as the current taps. - */ - void set_taps (tap_type alpha) - { - if (alpha < 0 || alpha > 1) - throw std::out_of_range ("Alpha must be in [0, 1]\n"); - - d_alpha = alpha; - d_one_minus_alpha = 1.0 - alpha; - } - - //! reset state to zero - void reset () - { - d_prev_input = 0; - } - - tap_type prev_input () { return d_prev_input; } - -protected: - tap_type d_alpha; - tap_type d_one_minus_alpha; - tap_type d_prev_input; -}; - - -// -// general case. We may want to specialize this -// -template<class o_type, class i_type, class tap_type> -o_type -gr_single_zero_avg<o_type, i_type, tap_type>::filter (const i_type input) -{ - tap_type output; - - output = d_alpha * input + d_one_minus_alpha * d_prev_input; - d_prev_input = input; - - return (o_type) output; -} - - -template<class o_type, class i_type, class tap_type> -void -gr_single_zero_avg<o_type, i_type, tap_type>::filterN (o_type output[], - const i_type input[], - unsigned long n) -{ - for (unsigned i = 0; i < n; i++) - output[i] = filter (input[i]); -} - - -#endif /* _GR_SINGLE_ZERO_AVG_H_ */ diff --git a/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.cc b/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.cc deleted file mode 100644 index cd07d55b7..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_single_zero_avg_filter_ff.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_single_zero_avg_filter_ff_sptr -gr_make_single_zero_avg_filter_ff (double alpha, unsigned int vlen) -{ - return gr_single_zero_avg_filter_ff_sptr(new gr_single_zero_avg_filter_ff(alpha, vlen)); -} - -gr_single_zero_avg_filter_ff::gr_single_zero_avg_filter_ff ( - double alpha, unsigned int vlen) - : gr_sync_block ("single_zero_avg_filter_ff", - gr_make_io_signature (1, 1, sizeof (float) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen), d_rec(vlen) -{ - set_taps(alpha); -} - -gr_single_zero_avg_filter_ff::~gr_single_zero_avg_filter_ff () -{ - // nop -} - -void -gr_single_zero_avg_filter_ff::set_taps (double alpha) -{ - for (unsigned int i = 0; i < d_vlen; i++) - d_rec[i].set_taps(alpha); -} - -int -gr_single_zero_avg_filter_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - unsigned int vlen = d_vlen; - - if (d_vlen == 1){ - for (int i = 0; i < noutput_items; i++) - out[i] = d_rec[0].filter (in[i]); - } - else { - for (int i = 0; i < noutput_items; i++){ - for (unsigned int j = 0; j < vlen; j++){ - *out++ = d_rec[j].filter (*in++); - } - } - } - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.h b/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.h deleted file mode 100644 index 14e1ef7c6..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SINGLE_ZERO_REC_FILTER_FF_H -#define INCLUDED_GR_SINGLE_ZERO_REC_FILTER_FF_H - -#include <gr_sync_block.h> -#include <gr_single_zero_avg.h> -#include <stdexcept> - -class gr_single_zero_avg_filter_ff; -typedef boost::shared_ptr<gr_single_zero_avg_filter_ff> gr_single_zero_avg_filter_ff_sptr; - -gr_single_zero_avg_filter_ff_sptr -gr_make_single_zero_avg_filter_ff (double alpha, unsigned int vlen=1); - -/*! - * \brief single zero moving average filter with float input, float output - * \ingroup filter - * - * The input and output satisfy a difference equation of the form - - \f[ - y[n] - (1-alpha) y[n-1] = alpha x[n] - \f] - - * with the corresponding rational system function - - \f[ - H(z) = \frac{alpha}{1 - (1-alpha) z^{-1}} - \f] - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback tap. - */ -class gr_single_zero_avg_filter_ff : public gr_sync_block -{ - private: - friend gr_single_zero_avg_filter_ff_sptr - gr_make_single_zero_avg_filter_ff (double alpha, unsigned int vlen); - - unsigned int d_vlen; - std::vector<gr_single_zero_avg<float,float,double> > d_rec; - - gr_single_zero_avg_filter_ff (double alpha, unsigned int vlen); - - public: - ~gr_single_zero_avg_filter_ff (); - - void set_taps (double alpha); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.i b/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.i deleted file mode 100644 index 4715249e5..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_zero_avg_filter_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,single_zero_avg_filter_ff); - -gr_single_zero_avg_filter_ff_sptr -gr_make_single_zero_avg_filter_ff (double alpha, unsigned int vlen=1); - -class gr_single_zero_avg_filter_ff : public gr_sync_block -{ - public: - ~gr_single_zero_avg_filter_ff (); - - void set_taps (double alpha); -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_zero_rec.h b/gnuradio-core/src/lib/filter/gr_single_zero_rec.h deleted file mode 100644 index 461ef5fa9..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_zero_rec.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef _GR_SINGLE_ZERO_REC_H_ -#define _GR_SINGLE_ZERO_REC_H_ - -#include <stdexcept> - -/*! - * \brief class template for single zero recursive filter - */ -template<class o_type, class i_type, class tap_type> -class gr_single_zero_rec { -public: - /*! - * \brief construct new single zero IIR with given alpha - * - * computes y(i) = alpha * x(i) - (1-alpha) * y(i-1) - */ - gr_single_zero_rec (tap_type alpha = 1.0) - { - d_prev_output = 0; - set_taps (alpha); - } - - /*! - * \brief compute a single output value. - * \returns the filtered input value. - */ - o_type filter (const i_type input); - - /*! - * \brief compute an array of N output values. - * \p input must have n valid entries. - */ - void filterN (o_type output[], const i_type input[], unsigned long n); - - /*! - * \brief install \p alpha as the current taps. - */ - void set_taps (tap_type alpha) - { - if (alpha < 0 || alpha > 1) - throw std::out_of_range ("Alpha must be in [0, 1]\n"); - - d_alpha = alpha; - d_one_minus_alpha = 1.0 - alpha; - } - - //! reset state to zero - void reset () - { - d_prev_output = 0; - } - - tap_type prev_output () { return d_prev_output; } - -protected: - tap_type d_alpha; - tap_type d_one_minus_alpha; - tap_type d_prev_output; -}; - - -// -// general case. We may want to specialize this -// -template<class o_type, class i_type, class tap_type> -o_type -gr_single_zero_rec<o_type, i_type, tap_type>::filter (const i_type input) -{ - tap_type output; - - output = d_alpha * input - d_one_minus_alpha * d_prev_output; - d_prev_output = output; - - return (o_type) output; -} - - -template<class o_type, class i_type, class tap_type> -void -gr_single_zero_rec<o_type, i_type, tap_type>::filterN (o_type output[], - const i_type input[], - unsigned long n) -{ - for (unsigned i = 0; i < n; i++) - output[i] = filter (input[i]); -} - - -#endif /* _GR_SINGLE_ZERO_REC_H_ */ diff --git a/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.cc b/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.cc deleted file mode 100644 index 57c4d53d1..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_single_zero_rec_filter_ff.h> -#include <gr_io_signature.h> -#include <stdio.h> - - -gr_single_zero_rec_filter_ff_sptr -gr_make_single_zero_rec_filter_ff (double alpha, unsigned int vlen) -{ - return gr_single_zero_rec_filter_ff_sptr(new gr_single_zero_rec_filter_ff(alpha, vlen)); -} - -gr_single_zero_rec_filter_ff::gr_single_zero_rec_filter_ff ( - double alpha, unsigned int vlen) - : gr_sync_block ("single_zero_rec_filter_ff", - gr_make_io_signature (1, 1, sizeof (float) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen), d_rec(vlen) -{ - set_taps(alpha); -} - -gr_single_zero_rec_filter_ff::~gr_single_zero_rec_filter_ff () -{ - // nop -} - -void -gr_single_zero_rec_filter_ff::set_taps (double alpha) -{ - for (unsigned int i = 0; i < d_vlen; i++) - d_rec[i].set_taps(alpha); -} - -int -gr_single_zero_rec_filter_ff::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - unsigned int vlen = d_vlen; - - if (d_vlen == 1){ - for (int i = 0; i < noutput_items; i++) - out[i] = d_rec[0].filter (in[i]); - } - else { - for (int i = 0; i < noutput_items; i++){ - for (unsigned int j = 0; j < vlen; j++){ - *out++ = d_rec[j].filter (*in++); - } - } - } - return noutput_items; -}; diff --git a/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.h b/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.h deleted file mode 100644 index 989d94090..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SINGLE_POLE_REC_FILTER_FF_H -#define INCLUDED_GR_SINGLE_POLE_REC_FILTER_FF_H - -#include <gr_sync_block.h> -#include <gr_single_zero_rec.h> -#include <stdexcept> - -class gr_single_zero_rec_filter_ff; -typedef boost::shared_ptr<gr_single_zero_rec_filter_ff> gr_single_zero_rec_filter_ff_sptr; - -gr_single_zero_rec_filter_ff_sptr -gr_make_single_zero_rec_filter_ff (double alpha, unsigned int vlen=1); - -/*! - * \brief single zero recursive filter with float input, float output - * \ingroup filter - * - * The input and output satisfy a difference equation of the form - - \f[ - y[n] - (1-alpha) y[n-1] = -alpha x[n] - \f] - - * with the corresponding system function - - \f[ - H(z) = {alpha - (1-alpha) z^{-1}} - \f] - - * Note that some texts define the system function with a + in the denominator. - * If you're using that convention, you'll need to negate the feedback tap. - */ -class gr_single_zero_rec_filter_ff : public gr_sync_block -{ - private: - friend gr_single_zero_rec_filter_ff_sptr - gr_make_single_zero_rec_filter_ff (double alpha, unsigned int vlen); - - unsigned int d_vlen; - std::vector<gr_single_zero_rec<float,float,double> > d_rec; - - gr_single_zero_rec_filter_ff (double alpha, unsigned int vlen); - - public: - ~gr_single_zero_rec_filter_ff (); - - void set_taps (double alpha); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.i b/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.i deleted file mode 100644 index 1aa896c47..000000000 --- a/gnuradio-core/src/lib/filter/gr_single_zero_rec_filter_ff.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,single_zero_rec_filter_ff); - -gr_single_zero_rec_filter_ff_sptr -gr_make_single_zero_rec_filter_ff (double alpha, unsigned int vlen=1); - -class gr_single_zero_rec_filter_ff : public gr_sync_block -{ - public: - ~gr_single_zero_rec_filter_ff (); - - void set_taps (double alpha); -}; |