summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-04-15 13:20:06 -0400
committerTom Rondeau <trondeau@vt.edu>2013-04-15 13:20:06 -0400
commit5cb0d3f04a6329cdb2c3443951185c8a3e5deba3 (patch)
tree9d8265a6d60a0a4629b8b48022c8d902617391bb
parent183d6eed0dca917a6d630604159b5becb7ccbcdc (diff)
parent3f15981d084246287c6cf1cde77064b45e53d6b4 (diff)
Merge branch 'next_fractional_resampler' into next
-rw-r--r--gr-filter/grc/CMakeLists.txt1
-rw-r--r--gr-filter/grc/filter_block_tree.xml2
-rw-r--r--gr-filter/grc/filter_fractional_resampler_xx.xml46
-rw-r--r--gr-filter/include/filter/CMakeLists.txt2
-rw-r--r--gr-filter/include/filter/fractional_resampler_cc.h60
-rw-r--r--gr-filter/include/filter/fractional_resampler_ff.h60
-rw-r--r--gr-filter/lib/CMakeLists.txt2
-rw-r--r--gr-filter/lib/fractional_interpolator_cc_impl.cc2
-rw-r--r--gr-filter/lib/fractional_interpolator_ff_impl.cc2
-rw-r--r--gr-filter/lib/fractional_resampler_cc_impl.cc125
-rw-r--r--gr-filter/lib/fractional_resampler_cc_impl.h61
-rw-r--r--gr-filter/lib/fractional_resampler_ff_impl.cc125
-rw-r--r--gr-filter/lib/fractional_resampler_ff_impl.h61
-rw-r--r--gr-filter/python/qa_fractional_resampler.py101
-rw-r--r--gr-filter/swig/filter_swig.i6
15 files changed, 655 insertions, 1 deletions
diff --git a/gr-filter/grc/CMakeLists.txt b/gr-filter/grc/CMakeLists.txt
index 3a2af83da9..cc5c77ebc6 100644
--- a/gr-filter/grc/CMakeLists.txt
+++ b/gr-filter/grc/CMakeLists.txt
@@ -24,6 +24,7 @@ install(FILES
filter_fir_filter_xxx.xml
filter_filter_delay_fc.xml
filter_fractional_interpolator_xx.xml
+ filter_fractional_resampler_xx.xml
filter_freq_xlating_fir_filter_xxx.xml
filter_hilbert_fc.xml
filter_iir_filter_ffd.xml
diff --git a/gr-filter/grc/filter_block_tree.xml b/gr-filter/grc/filter_block_tree.xml
index 614cfc0ec9..617893ad54 100644
--- a/gr-filter/grc/filter_block_tree.xml
+++ b/gr-filter/grc/filter_block_tree.xml
@@ -48,7 +48,7 @@
</cat>
<cat>
<name>Resamplers</name>
- <block>fractional_interpolator_xx</block>
+ <block>fractional_resampler_xx</block>
<block>pfb_arb_resampler_xxx</block>
<block>rational_resampler_xxx</block>
<block>rational_resampler_base_xxx</block>
diff --git a/gr-filter/grc/filter_fractional_resampler_xx.xml b/gr-filter/grc/filter_fractional_resampler_xx.xml
new file mode 100644
index 0000000000..48d624d432
--- /dev/null
+++ b/gr-filter/grc/filter_fractional_resampler_xx.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Fractional Resampler
+###################################################
+ -->
+<block>
+ <name>Fractional Resampler</name>
+ <key>fractional_resampler_xx</key>
+ <import>from gnuradio import filter</import>
+ <make>filter.fractional_resampler_$(type.fcn)($phase_shift, $resamp_ratio)</make>
+ <callback>set_resamp_ratio($resamp_ratio)</callback>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:cc</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ </option>
+ </param>
+ <param>
+ <name>Phase Shift</name>
+ <key>phase_shift</key>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Resampling Ratio</name>
+ <key>resamp_ratio</key>
+ <type>real</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-filter/include/filter/CMakeLists.txt b/gr-filter/include/filter/CMakeLists.txt
index d81f6b6607..a1595f1e9a 100644
--- a/gr-filter/include/filter/CMakeLists.txt
+++ b/gr-filter/include/filter/CMakeLists.txt
@@ -100,6 +100,8 @@ install(FILES
fft_filter_fff.h
fractional_interpolator_cc.h
fractional_interpolator_ff.h
+ fractional_resampler_cc.h
+ fractional_resampler_ff.h
hilbert_fc.h
iir_filter_ffd.h
pfb_arb_resampler_ccf.h
diff --git a/gr-filter/include/filter/fractional_resampler_cc.h b/gr-filter/include/filter/fractional_resampler_cc.h
new file mode 100644
index 0000000000..ad4eee9494
--- /dev/null
+++ b/gr-filter/include/filter/fractional_resampler_cc.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2012-2013 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_FRACTIONAL_RESAMPLER_CC_H
+#define INCLUDED_FRACTIONAL_RESAMPLER_CC_H
+
+#include <filter/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace filter {
+
+ /*!
+ * \brief resampling MMSE filter with complex input, complex output
+ * \ingroup resamplers_blk
+ */
+ class FILTER_API fractional_resampler_cc : virtual public gr_block
+ {
+ public:
+ // gr::filter::fractional_resampler_cc::sptr
+ typedef boost::shared_ptr<fractional_resampler_cc> sptr;
+
+ /*!
+ * \brief Build the resampling MMSE filter (complex input, complex output)
+ *
+ * \param phase_shift The phase shift of the output signal to the input
+ * \param resamp_ratio The resampling ratio = input_rate / output_rate.
+ */
+ static sptr make(float phase_shift,
+ float resamp_ratio);
+
+ virtual float mu() const = 0;
+ virtual float resamp_ratio() const = 0;
+ virtual void set_mu (float mu) = 0;
+ virtual void set_resamp_ratio(float resamp_ratio) = 0;
+ };
+
+ } /* namespace filter */
+} /* namespace gr */
+
+#endif /* INCLUDED_FRACTIONAL_RESAMPLER_FF_H */
diff --git a/gr-filter/include/filter/fractional_resampler_ff.h b/gr-filter/include/filter/fractional_resampler_ff.h
new file mode 100644
index 0000000000..53fba9f029
--- /dev/null
+++ b/gr-filter/include/filter/fractional_resampler_ff.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2012-2013 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_FRACTIONAL_RESAMPLER_FF_H
+#define INCLUDED_FRACTIONAL_RESAMPLER_FF_H
+
+#include <filter/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace filter {
+
+ /*!
+ * \brief Resampling MMSE filter with float input, float output
+ * \ingroup resamplers_blk
+ */
+ class FILTER_API fractional_resampler_ff : virtual public gr_block
+ {
+ public:
+ // gr::filter::fractional_resampler_ff::sptr
+ typedef boost::shared_ptr<fractional_resampler_ff> sptr;
+
+ /*!
+ * \brief Build the resampling MMSE filter (float input, float output)
+ *
+ * \param phase_shift The phase shift of the output signal to the input
+ * \param resamp_ratio The resampling ratio = input_rate / output_rate.
+ */
+ static sptr make(float phase_shift,
+ float resamp_ratio);
+
+ virtual float mu() const = 0;
+ virtual float resamp_ratio() const = 0;
+ virtual void set_mu (float mu) = 0;
+ virtual void set_resamp_ratio(float resamp_ratio) = 0;
+ };
+
+ } /* namespace filter */
+} /* namespace gr */
+
+#endif /* INCLUDED_FRACTIONAL_RESAMPLER_FF_H */
diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt
index c4d247785f..54f4e0992a 100644
--- a/gr-filter/lib/CMakeLists.txt
+++ b/gr-filter/lib/CMakeLists.txt
@@ -134,6 +134,8 @@ list(APPEND filter_sources
fft_filter_fff_impl.cc
fractional_interpolator_cc_impl.cc
fractional_interpolator_ff_impl.cc
+ fractional_resampler_cc_impl.cc
+ fractional_resampler_ff_impl.cc
hilbert_fc_impl.cc
iir_filter_ffd_impl.cc
pfb_arb_resampler_ccf_impl.cc
diff --git a/gr-filter/lib/fractional_interpolator_cc_impl.cc b/gr-filter/lib/fractional_interpolator_cc_impl.cc
index 8fd89f437f..137f6ee9c4 100644
--- a/gr-filter/lib/fractional_interpolator_cc_impl.cc
+++ b/gr-filter/lib/fractional_interpolator_cc_impl.cc
@@ -46,6 +46,8 @@ namespace gr {
d_mu (phase_shift), d_mu_inc (interp_ratio),
d_interp(new mmse_fir_interpolator_cc())
{
+ GR_LOG_WARN(d_logger, "fractional_interpolator is deprecated. Please use fractional_resampler instead.");
+
if(interp_ratio <= 0)
throw std::out_of_range("interpolation ratio must be > 0");
if(phase_shift < 0 || phase_shift > 1)
diff --git a/gr-filter/lib/fractional_interpolator_ff_impl.cc b/gr-filter/lib/fractional_interpolator_ff_impl.cc
index 6b35dc1061..f9202166b0 100644
--- a/gr-filter/lib/fractional_interpolator_ff_impl.cc
+++ b/gr-filter/lib/fractional_interpolator_ff_impl.cc
@@ -46,6 +46,8 @@ namespace gr {
d_mu (phase_shift), d_mu_inc (interp_ratio),
d_interp(new mmse_fir_interpolator_ff())
{
+ GR_LOG_WARN(d_logger, "fractional_interpolator is deprecated. Please use fractional_resampler instead.");
+
if(interp_ratio <= 0)
throw std::out_of_range("interpolation ratio must be > 0");
if(phase_shift < 0 || phase_shift > 1)
diff --git a/gr-filter/lib/fractional_resampler_cc_impl.cc b/gr-filter/lib/fractional_resampler_cc_impl.cc
new file mode 100644
index 0000000000..965241fdb3
--- /dev/null
+++ b/gr-filter/lib/fractional_resampler_cc_impl.cc
@@ -0,0 +1,125 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2010,2012-2013 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_io_signature.h>
+#include "fractional_resampler_cc_impl.h"
+#include <stdexcept>
+
+namespace gr {
+ namespace filter {
+
+ fractional_resampler_cc::sptr
+ fractional_resampler_cc::make(float phase_shift, float resamp_ratio)
+ {
+ return gnuradio::get_initial_sptr
+ (new fractional_resampler_cc_impl(phase_shift, resamp_ratio));
+ }
+
+ fractional_resampler_cc_impl::fractional_resampler_cc_impl
+ (float phase_shift, float resamp_ratio)
+ : gr_block("fractional_resampler_cc",
+ gr_make_io_signature(1, 1, sizeof(gr_complex)),
+ gr_make_io_signature(1, 1, sizeof(gr_complex))),
+ d_mu(phase_shift), d_mu_inc(resamp_ratio),
+ d_resamp(new mmse_fir_interpolator_cc())
+ {
+ if(resamp_ratio <= 0)
+ throw std::out_of_range("resampling ratio must be > 0");
+ if(phase_shift < 0 || phase_shift > 1)
+ throw std::out_of_range("phase shift ratio must be > 0 and < 1");
+
+ set_relative_rate(1.0 / resamp_ratio);
+ }
+
+ fractional_resampler_cc_impl::~fractional_resampler_cc_impl()
+ {
+ delete d_resamp;
+ }
+
+ void
+ fractional_resampler_cc_impl::forecast(int noutput_items,
+ gr_vector_int &ninput_items_required)
+ {
+ unsigned ninputs = ninput_items_required.size();
+ for(unsigned i=0; i < ninputs; i++) {
+ ninput_items_required[i] =
+ (int)ceil((noutput_items * d_mu_inc) + d_resamp->ntaps());
+ }
+ }
+
+ int
+ fractional_resampler_cc_impl::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const gr_complex *in = (const gr_complex*)input_items[0];
+ gr_complex *out = (gr_complex*)output_items[0];
+
+ int ii = 0; // input index
+ int oo = 0; // output index
+
+ while(oo < noutput_items) {
+ out[oo++] = d_resamp->interpolate(&in[ii], d_mu);
+
+ double s = d_mu + d_mu_inc;
+ double f = floor(s);
+ int incr = (int)f;
+ d_mu = s - f;
+ ii += incr;
+ }
+
+ consume_each(ii);
+
+ return noutput_items;
+ }
+
+ float
+ fractional_resampler_cc_impl::mu() const
+ {
+ return d_mu;
+ }
+
+ float
+ fractional_resampler_cc_impl::resamp_ratio() const
+ {
+ return d_mu_inc;
+ }
+
+ void
+ fractional_resampler_cc_impl::set_mu(float mu)
+ {
+ d_mu = mu;
+ }
+
+ void
+ fractional_resampler_cc_impl::set_resamp_ratio(float resamp_ratio)
+ {
+ d_mu_inc = resamp_ratio;
+ }
+
+ } /* namespace filter */
+} /* namespace gr */
diff --git a/gr-filter/lib/fractional_resampler_cc_impl.h b/gr-filter/lib/fractional_resampler_cc_impl.h
new file mode 100644
index 0000000000..15f36f9bb9
--- /dev/null
+++ b/gr-filter/lib/fractional_resampler_cc_impl.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2012-2013 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_FRACTIONAL_RESAMPLER_CC_IMPL_H
+#define INCLUDED_FRACTIONAL_RESAMPLER_CC_IMPL_H
+
+#include <filter/fractional_resampler_cc.h>
+#include <filter/mmse_fir_interpolator_cc.h>
+
+namespace gr {
+ namespace filter {
+
+ class FILTER_API fractional_resampler_cc_impl
+ : public fractional_resampler_cc
+ {
+ private:
+ float d_mu;
+ float d_mu_inc;
+ mmse_fir_interpolator_cc *d_resamp;
+
+ public:
+ fractional_resampler_cc_impl(float phase_shift,
+ float resamp_ratio);
+ ~fractional_resampler_cc_impl();
+
+ void forecast(int noutput_items,
+ gr_vector_int &ninput_items_required);
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ float mu() const;
+ float resamp_ratio() const;
+ void set_mu(float mu);
+ void set_resamp_ratio(float resamp_ratio);
+ };
+
+ } /* namespace filter */
+} /* namespace gr */
+
+#endif /* INCLUDED_FRACTIONAL_RESAMPLER_CC_IMPL_H */
diff --git a/gr-filter/lib/fractional_resampler_ff_impl.cc b/gr-filter/lib/fractional_resampler_ff_impl.cc
new file mode 100644
index 0000000000..cf7a9f462f
--- /dev/null
+++ b/gr-filter/lib/fractional_resampler_ff_impl.cc
@@ -0,0 +1,125 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2010,2013 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_io_signature.h>
+#include "fractional_resampler_ff_impl.h"
+#include <stdexcept>
+
+namespace gr {
+ namespace filter {
+
+ fractional_resampler_ff::sptr
+ fractional_resampler_ff::make(float phase_shift, float resamp_ratio)
+ {
+ return gnuradio::get_initial_sptr
+ (new fractional_resampler_ff_impl(phase_shift, resamp_ratio));
+ }
+
+ fractional_resampler_ff_impl::fractional_resampler_ff_impl
+ (float phase_shift, float resamp_ratio)
+ : gr_block("fractional_resampler_ff",
+ gr_make_io_signature(1, 1, sizeof(float)),
+ gr_make_io_signature(1, 1, sizeof(float))),
+ d_mu (phase_shift), d_mu_inc (resamp_ratio),
+ d_resamp(new mmse_fir_interpolator_ff())
+ {
+ if(resamp_ratio <= 0)
+ throw std::out_of_range("resampling ratio must be > 0");
+ if(phase_shift < 0 || phase_shift > 1)
+ throw std::out_of_range("phase shift ratio must be > 0 and < 1");
+
+ set_relative_rate(1.0 / resamp_ratio);
+ }
+
+ fractional_resampler_ff_impl::~fractional_resampler_ff_impl()
+ {
+ delete d_resamp;
+ }
+
+ void
+ fractional_resampler_ff_impl::forecast(int noutput_items,
+ gr_vector_int &ninput_items_required)
+ {
+ unsigned ninputs = ninput_items_required.size();
+ for(unsigned i=0; i < ninputs; i++) {
+ ninput_items_required[i] =
+ (int)ceil((noutput_items * d_mu_inc) + d_resamp->ntaps());
+ }
+ }
+
+ int
+ fractional_resampler_ff_impl::general_work(int noutput_items,
+ gr_vector_int &ninput_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];
+
+ int ii = 0; // input index
+ int oo = 0; // output index
+
+ while(oo < noutput_items) {
+ out[oo++] = d_resamp->interpolate(&in[ii], d_mu);
+
+ double s = d_mu + d_mu_inc;
+ double f = floor(s);
+ int incr = (int)f;
+ d_mu = s - f;
+ ii += incr;
+ }
+
+ consume_each(ii);
+
+ return noutput_items;
+ }
+
+ float
+ fractional_resampler_ff_impl::mu() const
+ {
+ return d_mu;
+ }
+
+ float
+ fractional_resampler_ff_impl::resamp_ratio() const
+ {
+ return d_mu_inc;
+ }
+
+ void
+ fractional_resampler_ff_impl::set_mu(float mu)
+ {
+ d_mu = mu;
+ }
+
+ void
+ fractional_resampler_ff_impl::set_resamp_ratio(float resamp_ratio)
+ {
+ d_mu_inc = resamp_ratio;
+ }
+
+ } /* namespace filter */
+} /* namespace gr */
diff --git a/gr-filter/lib/fractional_resampler_ff_impl.h b/gr-filter/lib/fractional_resampler_ff_impl.h
new file mode 100644
index 0000000000..053a3ca040
--- /dev/null
+++ b/gr-filter/lib/fractional_resampler_ff_impl.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2012-2013 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_FRACTIONAL_RESAMPLER_FF_IMPL_H
+#define INCLUDED_FRACTIONAL_RESAMPLER_FF_IMPL_H
+
+#include <filter/fractional_resampler_ff.h>
+#include <filter/mmse_fir_interpolator_ff.h>
+
+namespace gr {
+ namespace filter {
+
+ class FILTER_API fractional_resampler_ff_impl
+ : public fractional_resampler_ff
+ {
+ private:
+ float d_mu;
+ float d_mu_inc;
+ mmse_fir_interpolator_ff *d_resamp;
+
+ public:
+ fractional_resampler_ff_impl(float phase_shift,
+ float resamp_ratio);
+ ~fractional_resampler_ff_impl();
+
+ void forecast(int noutput_items,
+ gr_vector_int &ninput_items_required);
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ float mu() const;
+ float resamp_ratio() const;
+ void set_mu(float mu);
+ void set_resamp_ratio(float resamp_ratio);
+ };
+
+ } /* namespace filter */
+} /* namespace gr */
+
+#endif /* INCLUDED_FRACTIONAL_RESAMPLER_FF_IMPL_H */
diff --git a/gr-filter/python/qa_fractional_resampler.py b/gr-filter/python/qa_fractional_resampler.py
new file mode 100644
index 0000000000..28178a310f
--- /dev/null
+++ b/gr-filter/python/qa_fractional_resampler.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+#
+# Copyright 2007,2010,2012,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import filter_swig as filter
+import blocks_swig as blocks
+import math
+
+def sig_source_f(samp_rate, freq, amp, N):
+ t = map(lambda x: float(x)/samp_rate, xrange(N))
+ y = map(lambda x: math.sin(2.*math.pi*freq*x), t)
+ return y
+
+def sig_source_c(samp_rate, freq, amp, N):
+ t = map(lambda x: float(x)/samp_rate, xrange(N))
+ y = map(lambda x: math.cos(2.*math.pi*freq*x) + \
+ 1j*math.sin(2.*math.pi*freq*x), t)
+ return y
+
+class test_fractional_resampler(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001_ff(self):
+ N = 10000 # number of samples to use
+ fs = 1000 # baseband sampling rate
+ rrate = 1.123 # resampling rate
+
+ freq = 10
+ data = sig_source_f(fs, freq, 1, N)
+ signal = blocks.vector_source_f(data)
+ op = filter.fractional_resampler_ff(0, rrate)
+ snk = blocks.vector_sink_f()
+
+ self.tb.connect(signal, op, snk)
+ self.tb.run()
+
+ Ntest = 5000
+ L = len(snk.data())
+ t = map(lambda x: float(x)/(fs/rrate), xrange(L))
+
+ phase = 0.1884
+ expected_data = map(lambda x: math.sin(2.*math.pi*freq*x+phase), t)
+
+ dst_data = snk.data()
+
+ self.assertFloatTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 3)
+
+
+ def test_002_cc(self):
+ N = 10000 # number of samples to use
+ fs = 1000 # baseband sampling rate
+ rrate = 1.123 # resampling rate
+
+ freq = 10
+ data = sig_source_c(fs, freq, 1, N)
+ signal = blocks.vector_source_c(data)
+ op = filter.fractional_resampler_cc(0.0, rrate)
+ snk = blocks.vector_sink_c()
+
+ self.tb.connect(signal, op, snk)
+ self.tb.run()
+
+ Ntest = 5000
+ L = len(snk.data())
+ t = map(lambda x: float(x)/(fs/rrate), xrange(L))
+
+ phase = 0.1884
+ expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
+ 1j*math.sin(2.*math.pi*freq*x+phase), t)
+
+ dst_data = snk.data()
+
+ self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 3)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(test_fractional_resampler, "test_fractional_resampler.xml")
diff --git a/gr-filter/swig/filter_swig.i b/gr-filter/swig/filter_swig.i
index 066a2e2aab..10d0d7d823 100644
--- a/gr-filter/swig/filter_swig.i
+++ b/gr-filter/swig/filter_swig.i
@@ -45,6 +45,8 @@
#include "filter/fft_filter_fff.h"
#include "filter/fractional_interpolator_cc.h"
#include "filter/fractional_interpolator_ff.h"
+#include "filter/fractional_resampler_cc.h"
+#include "filter/fractional_resampler_ff.h"
#include "filter/freq_xlating_fir_filter_ccc.h"
#include "filter/freq_xlating_fir_filter_ccf.h"
#include "filter/freq_xlating_fir_filter_fcc.h"
@@ -92,6 +94,8 @@
%include "filter/fft_filter_fff.h"
%include "filter/fractional_interpolator_cc.h"
%include "filter/fractional_interpolator_ff.h"
+%include "filter/fractional_resampler_cc.h"
+%include "filter/fractional_resampler_ff.h"
%include "filter/freq_xlating_fir_filter_ccc.h"
%include "filter/freq_xlating_fir_filter_ccf.h"
%include "filter/freq_xlating_fir_filter_fcc.h"
@@ -136,6 +140,8 @@ GR_SWIG_BLOCK_MAGIC2(filter, fft_filter_ccc);
GR_SWIG_BLOCK_MAGIC2(filter, fft_filter_fff);
GR_SWIG_BLOCK_MAGIC2(filter, fractional_interpolator_cc);
GR_SWIG_BLOCK_MAGIC2(filter, fractional_interpolator_ff);
+GR_SWIG_BLOCK_MAGIC2(filter, fractional_resampler_cc);
+GR_SWIG_BLOCK_MAGIC2(filter, fractional_resampler_ff);
GR_SWIG_BLOCK_MAGIC2(filter, freq_xlating_fir_filter_ccc);
GR_SWIG_BLOCK_MAGIC2(filter, freq_xlating_fir_filter_ccf);
GR_SWIG_BLOCK_MAGIC2(filter, freq_xlating_fir_filter_fcc);