diff options
author | Tom Rondeau | 2012-06-15 17:56:33 -0400 |
---|---|---|
committer | Tom Rondeau | 2012-06-15 17:56:33 -0400 |
commit | 3cd0ea45255e2ca43931b2f067ec82fc92f4293e (patch) | |
tree | 2fac0d60af7df883f9c71d89de0741beb07a2d5b /gr-filter/lib | |
parent | b70bcc34ce4bd778a56e91da4b061475cda7cb6d (diff) | |
download | gnuradio-3cd0ea45255e2ca43931b2f067ec82fc92f4293e.tar.gz gnuradio-3cd0ea45255e2ca43931b2f067ec82fc92f4293e.tar.bz2 gnuradio-3cd0ea45255e2ca43931b2f067ec82fc92f4293e.zip |
filter: adding IIR filter.
Include QA and GRC.
Diffstat (limited to 'gr-filter/lib')
-rw-r--r-- | gr-filter/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-filter/lib/iir_filter_ffd_impl.cc | 85 | ||||
-rw-r--r-- | gr-filter/lib/iir_filter_ffd_impl.h | 56 |
3 files changed, 142 insertions, 0 deletions
diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt index d661d01b6..7a8b5aa0b 100644 --- a/gr-filter/lib/CMakeLists.txt +++ b/gr-filter/lib/CMakeLists.txt @@ -120,6 +120,7 @@ list(APPEND filter_sources fft_filter_ccc_impl.cc fft_filter_fff_impl.cc hilbert_fc_impl.cc + iir_filter_ffd_impl.cc pfb_channelizer_ccf_impl.cc single_pole_iir_filter_cc_impl.cc single_pole_iir_filter_ff_impl.cc diff --git a/gr-filter/lib/iir_filter_ffd_impl.cc b/gr-filter/lib/iir_filter_ffd_impl.cc new file mode 100644 index 000000000..24bfad190 --- /dev/null +++ b/gr-filter/lib/iir_filter_ffd_impl.cc @@ -0,0 +1,85 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012 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 "iir_filter_ffd_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace filter { + + iir_filter_ffd::sptr + iir_filter_ffd::make(const std::vector<double> &fftaps, + const std::vector<double> &fbtaps) + { + return gnuradio::get_initial_sptr(new iir_filter_ffd_impl(fftaps, fbtaps)); + } + + iir_filter_ffd_impl::iir_filter_ffd_impl(const std::vector<double> &fftaps, + const std::vector<double> &fbtaps) + + : gr_sync_block("iir_filter_ffd", + gr_make_io_signature(1, 1, sizeof (float)), + gr_make_io_signature(1, 1, sizeof (float))), + d_updated(false) + { + d_iir = new kernel::iir_filter<float,float,double>(fftaps, fbtaps); + //d_iir = new gri_iir<float,float,double>(fftaps, fbtaps); + } + + iir_filter_ffd_impl::~iir_filter_ffd_impl() + { + delete d_iir; + } + + void + iir_filter_ffd_impl::set_taps(const std::vector<double> &fftaps, + const std::vector<double> &fbtaps) + { + d_new_fftaps = fftaps; + d_new_fbtaps = fbtaps; + d_updated = true; + } + + int + iir_filter_ffd_impl::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]; + + if(d_updated) { + d_iir->set_taps(d_new_fftaps, d_new_fbtaps); + d_updated = false; + } + + d_iir->filter_n(out, in, noutput_items); + return noutput_items; + }; + + } /* namespace filter */ +} /* namespace gr */ + diff --git a/gr-filter/lib/iir_filter_ffd_impl.h b/gr-filter/lib/iir_filter_ffd_impl.h new file mode 100644 index 000000000..45aab6c22 --- /dev/null +++ b/gr-filter/lib/iir_filter_ffd_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 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_IIR_FILTER_FFD_IMPL_H +#define INCLUDED_IIR_FILTER_FFD_IMPL_H + +#include <filter/iir_filter.h> +#include <filter/iir_filter_ffd.h> + +namespace gr { + namespace filter { + + class FILTER_API iir_filter_ffd_impl : public iir_filter_ffd + { + private: + bool d_updated; + kernel::iir_filter<float,float,double> *d_iir; + std::vector<double> d_new_fftaps; + std::vector<double> d_new_fbtaps; + + public: + iir_filter_ffd_impl(const std::vector<double> &fftaps, + const std::vector<double> &fbtaps); + ~iir_filter_ffd_impl(); + + void set_taps(const std::vector<double> &fftaps, + const std::vector<double> &fbtaps); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace filter */ +} /* namespace gr */ + +#endif /* INCLUDED_IIR_FILTER_FFD_IMPL_H */ |